User Defined Functions

User Defined Function Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

User Defined Function | Description
_ArrayAdd | Adds a specified value at the end of an existing array.
_ArrayBinarySearch | Uses the binary search algorithm to search through a 1-dimensional array.
_ArrayCreate | Create a small array and quickly assign values.
_ArrayDelete | Deletes the specified element from the given array.
_ArrayDisplay | Displays a 1-dimensional or 2-dimensional array in a ListView .
_ArrayInsert | Inserts the a new string at the specified element into the specified array.
_ArrayMax | Returns the highest value held in an array.
_ArrayMaxIndex | Returns the index where the highest value occurs in the array.
_ArrayMin | Returns the lowest value held in an array.
_ArrayMinIndex | Returns the index where the lowest value occurs in the array.
_ArrayPop | Returns the last element of an array, deleting that element from the array at the same time.
_ArrayPush | Add new values without increasing array size. Either by inserting at the end the new value and deleting the first one or vice versa.
_ArrayReverse | Takes the given array and reverses the order in which the elements appear in the array.
_ArraySearch | Finds an entry within an one-dimensional array. (Similar to _ArrayBinarySearch() except the array does not need to be sorted.)
_ArraySort | Sort a mutiple dimensional Array.
_ArraySwap | Swaps two elements of an array.
_ArrayToClip | Sends the contents of an array to the clipboard.
_ArrayToString | Places the elements of an array into a single string, separated by the specified delimiter.
_ArrayTrim | Trims all elements in an array a certain number of characters.
_ChooseColor | Creates a Color dialog box that enables the user to select a color.
_ChooseFont | Creates a Font dialog box that enables the user to choose attributes for a logical font.
_ClipPutFile | Copy Files to Clipboard Like Explorer does
_ColorGetBlue | Returns the blue component of a given color.
_ColorGetGreen | Returns the green component of a given color.
_ColorGetRed | Returns the red component of a given color.
_CompareVersion | Compares two file versions for equality.
_DateAdd | Calculates a new date based on a given date and add an interval.
_DateDayOfWeek | Returns the name of the weekday, based on the specified day.
_DateDaysInMonth | Returns the number of days in a month, based on the specified month and year.
_DateDiff | Returns the difference between 2 dates, expressed in the type requested.
_DateIsLeapYear | Checks a given year to see if it is a leap year.
_DateIsValid | Checks the given date to determine if it is a valid date.
_DateTimeFormat | Returns the date in the PC's regional settings format.
_DateTimeSplit | Split a string containing Date and Time into two separate Arrays.
_DateToDayOfWeek | Returns the weekdaynumber for a given date.
_DateToDayOfWeekISO | Returns the ISO weekdaynumber for a given date.
_DateToDayValue | Returns the daynumber since since noon 4713 BC January 1 for a given Gregorian date.
_DateToMonth | Returns the name of the Month, based on the specified month number.
_DayValueToDate | Add the given days since noon 4713 BC January 1 and returns the Gregorian date.
_Degree | Converts radians to degrees.
_FileCountLines | Returns the number of lines in the specified file.
_FileCreate | Creates or zero's out the length of the file specified.
_FileListToArray | lists files and\or folders in a specified path (Similar to using Dir with the /B Switch)
_FilePrint | Prints a plain text file.
_FileReadToArray | Reads the specified file into an array.
_FileWriteFromArray | Writes Array records to the specified file.
_FileWriteLog | Writes current date,time and the specified text to a log file.
_FileWriteToLine | Writes text to a specific line in a file.
_GetIP | Get public IP address of a network/computer.
_GUICtrlComboAddDir | Add names to the list displayed by the combo box
_GUICtrlComboAddString | Add a string to the list box of a combo box
_GUICtrlComboAutoComplete | AutoComplete a combo box input
_GUICtrlComboDeleteString | Delete a string in the list box of a combo box
_GUICtrlComboFindString | Return the index of matching item
_GUICtrlComboGetCount | Retrieve the number of items in the list box of a combo box
_GUICtrlComboGetCurSel | Retrieve the index of the currently selected item, if any, in the list box of a combo box
_GUICtrlComboGetDroppedControlRect | Retrieve the screen coordinates of a combo box in its dropped-down state.
_GUICtrlComboGetDroppedState | Determine whether the list box of a combo box is dropped down
_GUICtrlComboGetDroppedWidth | Retrieve the minimum allowable width, of the list box of a combo box
_GUICtrlComboGetEditSel | Get the starting and ending character positions of the current selection in the edit control of a combo box.
_GUICtrlComboGetExtendedUI | Determine whether a combo box has the default user interface or the extended user interface
_GUICtrlComboGetHorizontalExtent | Retrieve from a combo box the width, in pixels
_GUICtrlComboGetItemHeight | Determine the height of list items or the selection field in a combo box
_GUICtrlComboGetLBText | Retrieve a string from the list of a combo box.
_GUICtrlComboGetLBTextLen | Retrieve the length, in characters, of a string in the list of a combo box
_GUICtrlComboGetList | Retrieves all items from the list portion of a ComboBox control.
_GUICtrlComboGetLocale | Retrieve the current locale of the combo box
_GUICtrlComboGetMinVisible | Get the minimum number of visible items in the drop-down list of a combo box
_GUICtrlComboGetTopIndex | Retrieve the zero-based index of the first visible item in the list box portion of a combo box
_GUICtrlComboInitStorage | Allocates memory for storing list box portion of the combo box items
_GUICtrlComboInsertString | Insert a string into the list box of a combo box
_GUICtrlComboLimitText | Limit the length of the text the user may type into the edit control of a combo box
_GUICtrlComboResetContent | Remove all items from the list box and edit control of a combo box
_GUICtrlComboSelectString | Search the list of a combo box for an item that begins with the characters in a specified string
_GUICtrlComboSetCurSel | Select a string in the list of a combo box
_GUICtrlComboSetDroppedWidth | Set the maximum allowable width
_GUICtrlComboSetEditSel | Select characters in the edit control of a combo box
_GUICtrlComboSetExtendedUI | Select either the default user interface or the extended user interface
_GUICtrlComboSetHorizontalExtent | Set the width, in pixels
_GUICtrlComboSetItemHeight | Set the height of list items or the selection field in a combo box
_GUICtrlComboSetMinVisible | Set the minimum number of visible items in the drop-down list of a combo box
_GUICtrlComboSetTopIndex | Ensure that a particular item is visible
_GUICtrlComboShowDropDown | Show or hide the list box of a combo box
_GUICtrlEditCanUndo | Determines whether there are any actions in an edit control's undo queue.
_GUICtrlEditEmptyUndoBuffer | Resets the undo flag of an edit control.
_GUICtrlEditFind | Find/Replace text in an Edit control
_GUICtrlEditGetFirstVisibleLine | Retrieves the zero-based index of the uppermost visible line in a multiline edit control.
_GUICtrlEditGetLine | Copies a line of text from an edit control.
_GUICtrlEditGetLineCount | Retrieves the number of lines in a multiline edit control.
_GUICtrlEditGetModify | Retrieves the state of an edit control's modification flag.
_GUICtrlEditGetRECT | Retrieves the formatting rectangle of an edit control.
_GUICtrlEditGetSel | Retrieves the starting and ending character positions of the current selection in an edit control.
_GUICtrlEditLineFromChar | Retrieves the index of the line that contains the specified character index in a multiline edit control.
_GUICtrlEditLineIndex | Retrieves the character index of the first character of a specified line in a multiline edit control.
_GUICtrlEditLineLength | Retrieves the length, in characters, of a line in an edit control.
_GUICtrlEditLineScroll | Scrolls the text in a multiline edit control.
_GUICtrlEditReplaceSel | Replaces the current selection in an edit control with the specified text.
_GUICtrlEditScroll | Scrolls the text vertically in a multiline edit control.
_GUICtrlEditSetModify | Sets or clears the modification flag for an edit control.
_GUICtrlEditSetRECT | Sets the formatting rectangle of an edit control.
_GUICtrlEditSetSel | Selects a range of characters in an edit control.
_GUICtrlEditUndo | Undoes the last edit control operation in the control's undo queue.
_GUICtrlIpAddressClear | Clears the contents of the IP address control
_GUICtrlIpAddressCreate | Create a GUI IP Address Control
_GUICtrlIpAddressDelete | Deletes the IpAddress control
_GUICtrlIpAddressGet | Retrieves the address values for all four fields in the IP address control
_GUICtrlIpAddressIsBlank | Determines if all fields in the IP address control are blank
_GUICtrlIpAddressSet | Sets the address values for all four fields in the IP address control
_GUICtrlIpAddressSetFocus | Sets the keyboard focus to the specified field in the IP address control.
_GUICtrlIpAddressSetFont | Set the font for the control
_GUICtrlIpAddressSetRange | Sets the valid range for the specified field in the IP address control
_GUICtrlIpAddressShowHide | Shows/Hides the IP address control
_GUICtrlListAddDir | Add File/Folder names to the list displayed by the list box
_GUICtrlListAddItem | Add an item to the List
_GUICtrlListClear | Remove all items from the list box
_GUICtrlListCount | Get the number of items in the list box
_GUICtrlListDeleteItem | Delete an Item from the List
_GUICtrlListFindString | Return the index of matching item
_GUICtrlListGetAnchorIndex | Get the Anchor Index
_GUICtrlListGetCaretIndex | Return index of item that has the focus rectangle
_GUICtrlListGetHorizontalExtent | Retrieve from a list box the the scrollable width (pixels)
_GUICtrlListGetInfo | Retrieve the number of items per column in a specified list box.
_GUICtrlListGetItemRect | Retrieve the dimensions of the rectangle that bounds a list box item.
_GUICtrlListGetLocale | Current Locale of the listbox
_GUICtrlListGetSelCount | Get the number of items selected
_GUICtrlListGetSelItems | Get item indices of selected items
_GUICtrlListGetSelItemsText | Get the text of selected items
_GUICtrlListGetSelState | Get the selection state of item
_GUICtrlListGetText | Returns the item (string) at the specified index
_GUICtrlListGetTextLen | Alternative to StringLen
_GUICtrlListGetTopIndex | Retrieve the index of the first visible item in a list
_GUICtrlListInsertItem | Insert a string into the list
_GUICtrlListReplaceString | Replaces the text of an item at index
_GUICtrlListSelectedIndex | Return the index of selected item
_GUICtrlListSelectIndex | Select a string and scroll it into view, if necessary
_GUICtrlListSelectString | Select item using search string
_GUICtrlListSelItemRange | Select range by index in a multiple-selection list box
_GUICtrlListSelItemRangeEx | Selects items from $i_start to $i_stop
_GUICtrlListSetAnchorIndex | Set the Anchor Index
_GUICtrlListSetCaretIndex | Set the focus rectangle to the item at the specified index.
_GUICtrlListSetHorizontalExtent | Set the width, in pixels, by which a list box can be scrolled horizontally
_GUICtrlListSetLocale | Set the locale
_GUICtrlListSetSel | Select string(s) in a multiple-selection list box
_GUICtrlListSetTopIndex | Ensure that a particular item in a list box is visible
_GUICtrlListSort | Re-sorts list box if it has the $LBS_SORT style
_GUICtrlListSwapString | Swaps the text of two items at the specified indices
_GUICtrlListViewCopyItems | Copy Items between 2 list-view controls
_GUICtrlListViewDeleteAllItems | Removes all items from a list-view control
_GUICtrlListViewDeleteColumn | Removes a column from a list-view control
_GUICtrlListViewDeleteItem | Removes an item from a list-view control
_GUICtrlListViewDeleteItemsSelected | Deletes item(s) selected
_GUICtrlListViewEnsureVisible | Ensures that a list-view item is either entirely or partially visible
_GUICtrlListViewFindItem | Retrieves some or all of a list-view item
_GUICtrlListViewGetBackColor | Retrieves the background color of a list-view control
_GUICtrlListViewGetCallBackMask | Retrieves the callback mask for a list-view control
_GUICtrlListViewGetCheckedState | Returns the check state for a list-view control item
_GUICtrlListViewGetColumnOrder | Retrieves the current left-to-right order of columns in a list-view control.
_GUICtrlListViewGetColumnWidth | Retrieves the width of a column in report or list view
_GUICtrlListViewGetCounterPage | Calculates the number of items that can fit vertically in the visible area of a list-view control
_GUICtrlListViewGetCurSel | Retrieve the index of current selection
_GUICtrlListViewGetExtendedListViewStyle | Retrieves the extended styles that are currently in use for a given list-view control
_GUICtrlListViewGetHeader | Retrieves the handle to the header control used by the list-view control
_GUICtrlListViewGetHotCursor | Retrieves the HCURSOR value used when the pointer is over an item while hot tracking is enabled
_GUICtrlListViewGetHotItem | Retrieves the index of the hot item
_GUICtrlListViewGetHoverTime | Retrieves the amount of time that the mouse cursor must hover over an item before it is selected
_GUICtrlListViewGetItemCount | Retrieves the number of items in a list-view control
_GUICtrlListViewGetItemText | Retrieves some or all of a list-view item
_GUICtrlListViewGetItemTextArray | Retrieves all of a list-view item
_GUICtrlListViewGetNextItem | Returns the index of the next item
_GUICtrlListViewGetSelectedCount | Determines the number of selected items in a list-view control
_GUICtrlListViewGetSelectedIndices | Retrieve indices of selected item(s) in a list-view control
_GUICtrlListViewGetSubItemsCount | Retrieve the number of columns
_GUICtrlListViewGetTopIndex | Retrieves the index of the topmost visible item when in list or report view
_GUICtrlListViewGetUnicodeFormat | Retrieves the UNICODE character format flag for the control
_GUICtrlListViewHideColumn | Hides the column "sets column width to zero"
_GUICtrlListViewInsertColumn | Inserts a column into a list-view control
_GUICtrlListViewInsertItem | Inserts a new item in a list-view control.
_GUICtrlListViewJustifyColumn | Set Justification of a column for a list-view control
_GUICtrlListViewScroll | Scrolls the content of a list-view control
_GUICtrlListViewSetCheckState | Sets the checked state of a list-view control item
_GUICtrlListViewSetColumnHeaderText | Change the text of a column header for a list-view control
_GUICtrlListViewSetColumnOrder | Sets the left-to-right order of columns in a list-view control.
_GUICtrlListViewSetColumnWidth | Changes the width of a column
_GUICtrlListViewSetHotItem | Sets the hot item for a list-view control
_GUICtrlListViewSetHoverTime | Sets the amount of time which the mouse cursor must hover over an item before it is selected
_GUICtrlListViewSetItemCount | Causes the list-view control to allocate memory for the specified number of items.
_GUICtrlListViewSetItemSelState | Sets the Item Selected/UnSelected
_GUICtrlListViewSetItemText | Changes the text of a list-view item or subitem.
_GUICtrlListViewSort | Sorts a list-view control.
_GUICtrlMonthCalGet1stDOW | Retrieves the first day of the week for a month calendar control.
_GUICtrlMonthCalGetColor | Retrieves the color for a given portion of a month calendar control.
_GUICtrlMonthCalGetDelta | Retrieves the scroll rate for a month calendar control.
_GUICtrlMonthCalGetMaxSelCount | Retrieves the maximum date range that can be selected in a month calendar control.
_GUICtrlMonthCalGetMaxTodayWidth | Retrieves the maximum width of the "today" string in a month calendar control.
_GUICtrlMonthCalGetMinReqRECT | Retrieves the minimum size required to display a full month in a month calendar control.
_GUICtrlMonthCalSet1stDOW | Sets the first day of the week for a month calendar control.
_GUICtrlMonthCalSetColor | Sets the color for a given portion of a month calendar control.
_GUICtrlMonthCalSetDelta | Sets the scroll rate for a month calendar control.
_GUICtrlMonthCalSetMaxSelCount | Sets the maximum number of days that can be selected in a month calendar control.
_GUICtrlSliderClearTics | Removes the current tick marks from a slider.
_GUICtrlSliderGetLineSize | Retrieves the number of logical positions the slider moves.
_GUICtrlSliderGetNumTics | Retrieves the number of tick marks from a slider.
_GUICtrlSliderGetPageSize | Retrieves the number of logical positions the slider moves.
_GUICtrlSliderGetPos | Retrieves the logical position the slider.
_GUICtrlSliderGetRangeMax | Retrieves the maximum position for the slider.
_GUICtrlSliderGetRangeMin | Retrieves the minimum position for the slider.
_GUICtrlSliderSetLineSize | Sets the number of logical positions the slider moves.
_GUICtrlSliderSetPageSize | Sets the number of logical positions the slider moves.
_GUICtrlSliderSetPos | Sets the current logical position of the slider.
_GUICtrlSliderSetTicFreq | Sets the interval frequency for tick marks in a slider.
_GUICtrlStatusBarCreate | Creates Statusbar
_GUICtrlStatusBarCreateProgress | Creates ProgressBar in Statusbar part
_GUICtrlStatusBarDelete | Deletes the StatusBar control
_GUICtrlStatusBarGetBorders | Retrieves the current widths of the horizontal and vertical borders of a status window.
_GUICtrlStatusBarGetIcon | Retrieves the icon for a part in a status bar.
_GUICtrlStatusBarGetParts | Retrieves a count of the parts in a status window.
_GUICtrlStatusBarGetRect | Retrieves the bounding rectangle of a part in a status window.
_GUICtrlStatusBarGetText | retrieves the text from the specified part of a status window.
_GUICtrlStatusBarGetTextLength | Retrieves the length, in characters, of the text from the specified part of a status window.
_GUICtrlStatusBarGetTip | Retrieves the ToolTip text for a part in a status bar.
_GUICtrlStatusBarGetUnicode | Retrieves the Unicode character format flag for the control.
_GUICtrlStatusBarIsSimple | Checks a status bar control to determine if it is in simple mode.
_GUICtrlStatusBarResize | Resize Statusbar.
_GUICtrlStatusBarSetBKColor | Sets the background color in a status bar.
_GUICtrlStatusBarSetIcon | Sets an Icon in the Panel.
_GUICtrlStatusBarSetMinHeight | Sets the minimum height of a status window's drawing area.
_GUICtrlStatusBarSetParts | Sets the number of parts in a status window and the coordinate of the right edge of each part.
_GUICtrlStatusBarSetSimple | Specifies whether a status window displays simple text or displays all window parts.
_GUICtrlStatusBarSetText | Sets the text in the specified part of a status window.
_GUICtrlStatusBarSetTip | Sets the ToolTip text for a part in a status bar.
_GUICtrlStatusBarSetUnicode | Sets the Unicode character format flag for the control.
_GUICtrlStatusBarShowHide | Show/Hide the StatusBar control
_GUICtrlTabDeleteAllItems | Removes all items from a tab control.
_GUICtrlTabDeleteItem | Removes an item from a tab control.
_GUICtrlTabDeselectAll | Resets items in a tab control.
_GUICtrlTabGetCurFocus | Returns the index of the item that has the focus in a tab control.
_GUICtrlTabGetCurSel | Determines the currently selected tab in a tab control.
_GUICtrlTabGetExtendedStyle | Retrieves the extended styles that are currently in use for the tab control.
_GUICtrlTabGetItemCount | Retrieves the number of tabs in the tab control.
_GUICtrlTabGetItemRECT | Retrieves the bounding rectangle for a tab in a tab control.
_GUICtrlTabGetRowCount | Retrieves the current number of rows of tabs in a tab control.
_GUICtrlTabGetUnicodeFormat | Retrieves the Unicode character format flag for the control.
_GUICtrlTabHighlightItem | Sets the highlight state of a tab item.
_GUICtrlTabSetCurFocus | Sets the focus to a specified tab in a tab control.
_GUICtrlTabSetCurSel | Selects a tab in a tab control.
_GUICtrlTabSetMinTabWidth | Sets the minimum width of items in a tab control.
_GUICtrlTabSetUnicodeFormat | Sets the Unicode character format flag for the control.
_GUICtrlTreeViewDeleteAllItems | Removes all items from a treeview control.
_GUICtrlTreeViewDeleteItem | Removes an item and all its children from a treeview control.
_GUICtrlTreeViewExpand | Expands or collapses the list of child items associated with the specified parent item, if any.
_GUICtrlTreeViewGetBkColor | Gets the text back color of a treeview control.
_GUICtrlTreeViewGetCount | Retrieves a count of the items in a treeview control.
_GUICtrlTreeViewGetIndent | Retrieves the amount in pixels, that child items are indented relative to their parent items.
_GUICtrlTreeViewGetLineColor | Gets the line color of a treeview control.
_GUICtrlTreeViewGetParentHandle | Gets the parent handle of item selected (default) or any specified item in treeview control.
_GUICtrlTreeViewGetParentID | Gets the parent control ID of item selected (default) or any specified item in treeview control.
_GUICtrlTreeViewGetState | Returns the state of the specified treeview item.
_GUICtrlTreeViewGetText | Returns the text of the specified treeview item.
_GUICtrlTreeViewGetTextColor | Gets the text color of a treeview control.
_GUICtrlTreeViewGetTree | Get all items text beginning by the current selected item from the treeview control.
_GUICtrlTreeViewInsertItem | Insert a new item into a treeview control.
_GUICtrlTreeViewSetBkColor | Sets the back color of a treeview control.
_GUICtrlTreeViewSetIcon | Set an icon of the specified treeview item.
_GUICtrlTreeViewSetIndent | Sets the width of indentation for a treeview control and redraws the control to reflect the new width.
_GUICtrlTreeViewSetLineColor | Sets the line color of a treeview control
_GUICtrlTreeViewSetState | Set the state of the specified treeview item.
_GUICtrlTreeViewSetText | Set a new text to the specified treeview item.
_GUICtrlTreeViewSetTextColor | Sets the text color of a treeview control.
_GUICtrlTreeViewSort | Sorts the items of a treeview control.
_HexToString | Convert a hex string to a string.
_IE_Example | Display a new browser window pre-loaded with documents to be used in IE.au3 examples or your own testing
_IE_Introduction | Display introductory information about IE.au3 in a new browser window
_IE_VersionInfo | Returns an array of information about the IE.au3 version
_IEAction | Perform any of a set of simple actions on the Browser.
_IEAttach | Attach to the first existing instance of Internet Explorer where the search string sub-string matches based on the selected mode.
_IEBodyReadHTML | Returns the HTML inside the <body> tag of the document.
_IEBodyReadText | Returns the Text inside the <body> tag of the document.
_IEBodyWriteHTML | Replaces the HTML inside the <body> tag of the document.
_IECreate | Create an Internet Explorer Browser Window.
_IECreateEmbedded | Create a Webbrowser object suitable for embedding in an AutoIt GUI with GuiCtrlCreateObj().
_IEDocGetObj | Given any DOM object, returns a reference to the associated document object.
_IEDocInsertHTML | Inserts HTML Text in or around an element.
_IEDocInsertText | Inserts Text in or around an element.
_IEDocReadHTML | Returns the full HTML source of a document.
_IEDocWriteHTML | Replaces the HTML for the entire document.
_IEErrorHandlerDeRegister | Disable a registered user COM error handler
_IEErrorHandlerRegister | Register and enable a user COM error handler
_IEErrorNotify | Specifies whether IE.au3 automatically notifies of Warnings and Errors (to the console)
_IEFormElementCheckBoxSelect | Set the value of a specified form element.
_IEFormElementGetCollection | Returns a collection object variable representing all Form Elements within a given Form.
_IEFormElementGetObjByName | Returns an object reference to a Form Element by name.
_IEFormElementGetValue | Returns the value of a given Form Element.
_IEFormElementOptionSelect | Set the value of a specified form element.
_IEFormElementRadioSelect | Set the value of a specified form element.
_IEFormElementSetValue | Set the value of a specified Form Element.
_IEFormGetCollection | Returns a collection object variable representing the Forms in the document or a single form by index.
_IEFormGetObjByName | Returns an object reference to a Form by name.
_IEFormImageClick | Simulate a mouse click on an <input type=image>. Match by sub-string match of alt text, name or src.
_IEFormReset | Reset a specified Form setting the values back to their loaded defaults.
_IEFormSubmit | Submit a specified Form.
_IEFrameGetCollection | Returns a collection object containing the frames in a FrameSet or the iFrames on a normal page or a single Frame or iFrame by index.
_IEFrameGetObjByName | Returns an object reference to a Frame or iFrame by name.
_IEGetObjById | Returns an object variable by id or name.
_IEGetObjByName | Returns an object variable by name or id.
_IEHeadInsertEventScript | Inserts a Javascript into the Head of the document.
_IEImgClick | Simulate a mouse click on an image. Match by sub-string match of alt text, name, or src.
_IEImgGetCollection | Returns a collection object variable representing the IMG tags in the document or a single image by index.
_IEIsFrameSet | Checks to see if the specified Window contains a FrameSet.
_IELinkClickByIndex | Simulate a mouse click on a link by 0-based index (in source order).
_IELinkClickByText | Simulate a mouse click on a link with text sub-string matching the string provided.
_IELinkGetCollection | Returns a collection object containing all links in the document or a single link by index.
_IELoadWait | Wait for a browser page load to complete before returning.
_IELoadWaitTimeout | Retrieve or set the current value in milliseconds _IELoadWait will try before timing out.
_IENavigate | Directs an existing browser window to navigate to the specified URL.
_IEPropertyGet | Returns a select property of the Browser or DOM element.
_IEPropertySet | Set a select property of the Browser or DOM element.
_IEQuit | Close the browser and remove the object reference to it.
_IETableGetCollection | Returns a collection object variable representing all the tables in a document or a single table by index.
_IETableWriteToArray | Reads the contents of a Table into an array.
_IETagNameAllGetCollection | Returns a collection object all elements in the document or document hierarchy in source order or a single element by index.
_IETagNameGetCollection | Returns a collection object of all elements in the object with the specified TagName or a single element by index.
_Iif | Perform a boolean test within an expression.
_INetExplorerCapable | Converts a string to IE(Internet Explorer) capable line
_INetGetSource | Gets the source from an URL without writing a temp file.
_INetMail | Opens default user's mail client with given address, subject, and body.
_INetSmtpMail | Sends an email without using an external email program.
_IsClassname | Check ClassName of the control.
_IsPressed | Check if key has been pressed
_MathCheckDiv | Checks if NumA is divisable by NumB
_Max | Evaluates which of the two numbers is higher.
_Min | Evaluates which of the two numbers is lower.
_MouseTrap | Confine the Mouse Cursor to specified coords.
_Now | Returns the current Date and Time in PC's format.
_NowCalc | Returns the current Date and Time in format YYYY/MM/DD HH:MM:SS for use in date calculations.
_NowCalcDate | Returns the current Date in format YYYY/MM/DD.
_NowDate | Returns the current Date in the Pc's format.
_NowTime | Returns the current Time in requested format.
_PathFull | Creates a path based on the relative path you provide. The newly created absolute path is returned
_PathMake | Creates a path from drive, directory, file name and file extension parts. Not all parts must be passed.
_PathSplit | Splits a path into the drive, directory, file name and file extension parts. An empty string is set if a part is missing.
_ProcessGetName | Returns a string containing the process name that belongs to a given PID.
_ProcessGetPriority | Get the priority of an open process
_Radian | Converts degrees to radians.
_ReplaceStringInFile | Replaces a string with another string in the given text file (binary won't work!)
_RunDOS | Executes a DOS command in a hidden command window.
_SendMessage | Wrapper for commonly used Dll Call
_SetDate | Sets the current date of the system
_SetTime | Sets the current time of the system
_Singleton | Check if no other occurrence is running.
_SoundClose | Closes a sound previously opened with _SoundOpen.
_SoundLength | Returns the length of the soundfile.
_SoundOpen | Opens a sound file for use with other _Sound functions.
_SoundPause | Pause a playing sound.
_SoundPlay | Play a sound file.
_SoundPos | Returns the current position of the sound.
_SoundResume | Resume a paused sound.
_SoundSeek | Seeks the sound to the specified position
_SoundStatus | Returns the status of the sound
_SoundPlay | Stop a playing sound.
_SQLite_Changes | Returns number of changes (excluding triggers) of the last transaction
_SQLite_Close | Close a SQLite database.
_SQLite_Display2DResult | Returns or prints a 2Dimensional array formated to Console
_SQLite_Encode | Encodes strings or binary data for use in SQLite query's
_SQLite_ErrCode | Returns last error code (numeric)
_SQLite_ErrMsg | Returns a string describing in english the error condition for the most recent sqlite3_* API call
_SQLite_Escape | Escapes a string
_SQLite_Exec | Executes a SQLite query, does not handle results.
_SQLite_FetchData | Fetches 1 row of data from a _SQLite_Query() based query
_SQLite_FetchNames | Read out the table names of a _SQLite_Query() based query
_SQLite_GetTable | Passes Out a 1Dimensional Array Containing Tablenames and Data of Executed Query.
_SQLite_GetTable2d | Passes out a 2Dimensional array containing table names and data of executed Query
_SQLite_LastInsertRowID | Returns the ROWID of the most recent insert in the database
_SQLite_LibVersion | Returns the version number of the library
_SQLite_Open | Opens/creates a SQLite database.
_SQLite_Query | Prepares a SQLite Query
_SQLite_QueryFinalize | Finalizes an _SQLite_Query() based query. The query is interrupted.
_SQLite_QueryReset | Reset a _SQLite_Query() based query
_SQLite_QuerySingleRow | Read out the first row of the result from the specified query.
_SQLite_SaveMode | Disable or Enable Save mode
_SQLite_SetTimeout | Sets timeout for busy handler
_SQLite_Shutdown | Unloads SQLite.dll
_SQLite_SQLiteExe | Executes commands in SQLite.exe
_SQLite_Startup | Loads SQLite.dll
_SQLite_TotalChanges | Returns number of all changes (including triggers) of all transactions
_StringAddComma | Returns the original numbered string with the proper delimiter inserted.
_StringBetween | Returns the string between the start search string and the end search string.
_StringEncrypt | An RC4 based string encryption function.
_StringInsert | Inserts a string within another string.
_StringProper | Changes a string to proper case, same a =Proper function in Excel
_StringRepeat | Repeats a string a specified number of times.
_StringReverse | Reverses the contents of the specified string.
_StringToHex | Convert a string to a hex string.
_TCPIpToName | Resolves IP adress to Hostname(s)
_TempFile | Generate a name for a temporary file. The file is guaranteed not to exist yet.
_TicksToTime | Converts the specified tick amount to hours, minutes and seconds.
_TimeToTicks | Converts the specified hours, minutes, and seconds to ticks.
_viClose | Closes a VISA connection to an Instrument/Device
_viExecCommand | Send a Command/Query to an Instrument/Device through the VISA interface (GPIB / TCP)
_viFindGpib | Send a Command/Query to an Instrument/Device through the VISA interface (GPIB / TCP)
_viGpibBusReset | GPIB BUS "reset": Use this function when the GPIB BUS gets stuck for some reason. You might be lucky and resolve the problem by calling this function
_viGTL | Go To Local mode: Instruments that accept this command will exit the "Remote Control mode" and go to "Local mode". If the instrument is already in "Local mode" this is simply ignored. Normally, if an instrument does not support this command it will simply stay in the "Remote Control mode"
_viOpen | Opens a VISA connection to an Instrument/Device
_viSetAttribute | Set any VISA attribute This function, which is called by _viSetTimeout, can ALSO be used to set the other VISA specific attributes. Read the VISA documentation for more information and a list of VISA attributes and their corresponding values.
_viSetTimeout | Sets the VISA timeout in MILISECONDS
_WeekNumberISO | Calculate the weeknumber of a given date.
_Word_VersionInfo | Returns an array of information about the Word.au3 version
_WordAttach | Attach to the first existing instance of Microsoft Word where the search string matches based on the selected mode.
_WordCreate | Create a Microsoft Office Word Object
_WordDocAdd | Returns an object variable representing a new empty document
_WordDocAddLink | Add a hyperlink to the document
_WordDocAddPicture | Add a picture to the document
_WordDocClose | Closes a previously opened word document
_WordDocFindReplace | Runs the specified find and replace operation.
_WordDocGetCollection | Returns a collection object containing all documents
_WordDocLinkGetCollection | Returns a collection object containing all links in the document
_WordDocOpen | Opens an existing Microsoft Word Document
_WordDocPrint | Prints all or part of the specified document.
_WordDocPropertyGet | Returns a select property of the Word Document.
_WordDocPropertySet | Set a select property of the Word Document
_WordDocSave | Saves a previously opened document
_WordDocSaveAs | Saves the specified document with a new name or format.
_WordErrorHandlerDeRegister | Disable a registered user COM error handler
_WordErrorHandlerRegister | Register and enable a user COM error handler
_WordErrorNotify | Specifies whether Word.au3 automatically notifies of Warnings and Errors (to the console)
_WordMacroRun | Runs a Visual Basic macro
_WordPropertyGet | Returns a select property of the Word Application.
_WordPropertySet | Set a select property of the Word Application.
_WordQuit | Close the window and remove the object reference to it


Function Notes

User Defined Function Notes

We have included number of files that each contain standard AutoIt3 Functions, so called User Defined Functions.
UDF's are functions/Scriptlets, written in AutoIt3, you can #include in your own script and use them without the need to program it yourself or Copy&Paste them every time you need them.

Example:

#include <date.au3>

MsgBox(0,"Today","Today's date is " & Now())

This script will display today's date formatted in your pc's long format. e.g. "Sunday, December 18, 2004"

Many UDF's contain optional parameters that can be omitted. If you wish to specify an optional parameter, however, all parameters that precede it must be specified!
For example, consider _ArraySort ( ByRef $a_Array, [[[[$i_Descending], $i_Base=0], $i_Ubound=0, $i_Dim=1]] )
When a parameters is preceded with Byref mean that the function will update this variable with a new value. These parameters must be a variable ($xyz) and cannot be a constant.

Most UDF's indicate success/failure as a return value; others indicate it by setting the @error flag. Some do both....
@error = 0 ;is always success
Return = varies, but is typically non-zero for success to allow easy to read code...

If a function can set the @error flag, you should always check it before using a return value - if @error indicates an error then the function return value is generally undefined...


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: Array Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_ArrayAdd | Adds a specified value at the end of an existing array.
_ArrayBinarySearch | Uses the binary search algorithm to search through a 1-dimensional array.
_ArrayCreate | Create a small array and quickly assign values.
_ArrayDelete | Deletes the specified element from the given array.
_ArrayDisplay | Displays a 1-dimensional or 2-dimensional array in a ListView .
_ArrayInsert | Inserts the a new string at the specified element into the specified array.
_ArrayMax | Returns the highest value held in an array.
_ArrayMaxIndex | Returns the index where the highest value occurs in the array.
_ArrayMin | Returns the lowest value held in an array.
_ArrayMinIndex | Returns the index where the lowest value occurs in the array.
_ArrayPop | Returns the last element of an array, deleting that element from the array at the same time.
_ArrayPush | Add new values without increasing array size. Either by inserting at the end the new value and deleting the first one or vice versa.
_ArrayReverse | Takes the given array and reverses the order in which the elements appear in the array.
_ArraySearch | Finds an entry within an one-dimensional array. (Similar to _ArrayBinarySearch() except the array does not need to be sorted.)
_ArraySort | Sort a mutiple dimensional Array.
_ArraySwap | Swaps two elements of an array.
_ArrayToClip | Sends the contents of an array to the clipboard.
_ArrayToString | Places the elements of an array into a single string, separated by the specified delimiter.
_ArrayTrim | Trims all elements in an array a certain number of characters.


Function _ArrayAdd

Function Reference

_ArrayAdd

Adds a specified value at the end of an existing array.

#include <Array.au3>
_ArrayAdd ( $avArray, $sValue )

Parameters

$avArray | The array to which the element is to be added.
$sValue | The value to be added.

Return Value

Success: | Returns 1 and the modified array.
Failure: | Returns a 1-element array with the value added to it.
@Error: | 0 = No error.
 | 1 = $avArray isn't an array.

Remarks

This function will return an array even if both parameters are empty strings (""). In this case it will return an array with 1-element that contains an empty string value.

Related

_ArrayDelete, _ArrayInsert

Example

#include <Array.au3>
Dim $avArray[10]
$avArray[0] = "JPM"
$avArray[1] = "Holger"
$avArray[2] = "Jon"
$avArray[3] = "Larry"
$avArray[4] = "Jeremy"
$avArray[5] = "Valik"
$avArray[6] = "Cyberslug"
$avArray[7] = "Nutster"
$avArray[8] = "JdeB"
$avArray[9] = "Tylo"
_ArrayDisplay( $avArray, "Whole array" )
_ArrayAdd( $avArray,"Brian")
_ArrayDisplay( $avArray, "Updated Array" )


Function _ArrayBinarySearch

Function Reference

_ArrayBinarySearch

Uses the binary search algorithm to search through a 1-dimensional array.

#include <Array.au3>
_ArrayBinarySearch ( $avArray, $iKey [, $i_Base=0 ] )

Parameters

$avArray | The 1-dimensional sorted array to search on.
$iKey | String or number to search for in the array.
$i_Base | Optional: Start Array index for sort, normally set to 0 or 1.

Return Value

Success: | Returns the key (index of where item is in the array).
Failure: | Returns an empty string.
@Error: | 0 = No error.
 | 1 = $avArray isn't an array.
 | 2 = $iKey is out of bounds.
 | 3 = If the item wasn't found in the array.

Remarks

When doing a binary search on an array of items, the contents MUST be sorted before the search is done. Otherwise undefined results will be returned.

The array is passed to the function by reference and so doesn't use up any additional resources other than a few internal variables.

Related

None.

Example

#include <Array.au3>
Dim $avArray[10]

$avArray[0] = "JPM"
$avArray[1] = "Holger"
$avArray[2] = "Jon"
$avArray[3] = "Larry"
$avArray[4] = "Jeremy"
$avArray[5] = "Valik"
$avArray[6] = "Cyberslug"
$avArray[7] = "Nutster"
$avArray[8] = "JdeB"
$avArray[9] = "Tylo"

; sort the array to be able to do a binary search
_ArraySort( $avArray)

; display sorted array
_ArrayDisplay( $avArray, "sorted" )

; Lookup existing entry
$iKeyIndex = _ArrayBinarySearch ( $avArray, "Jon" )
If Not @error Then
Msgbox(0,'Entry found',' Index:' & $iKeyIndex)
Else
Msgbox(0,'Entry Not found',' Error:' & @error)
EndIf

; Lookup None existing entry
$iKeyIndex = _ArrayBinarySearch ( $avArray, "Unknown" )
If Not @error Then
Msgbox(0,'Entry found',' Index:' & $iKeyIndex)
Else
Msgbox(0,'Entry Not found',' Error:' & @error)
EndIf

;
; Example 2, using an Array returned by StringSplit
;
$avArray = StringSplit("a,b,d,c,e,f,g,h,i",",")

; sort the array to be able to do a binary search
_ArraySort( $avArray, 0, 1)

; display sorted array
_ArrayDisplay( $avArray, "sorted" )

; added 1 as second parameter to skip looking in $avArray[0]
$iKeyIndex = _ArrayBinarySearch ( $avArray, "c",1 )
If Not @error Then
Msgbox(0,'Entry found',' Index:' & $iKeyIndex)
Else
Msgbox(0,'Entry Not found',' Error:' & @error)
EndIf

Exit


Function _ArrayCreate

Function Reference

_ArrayCreate

Create a small array and quickly assign values.

#include <Array.au3>
_ArrayCreate ( $v_Val1 [,$v_Val2 [,..., $v_Val21 ]] )

Parameters

$v_Val1 | The first element of the array.
$v_Val2 | Optional: The second element of the array.
. |
. |
. |
$v_Val21 | Optional: The twentyfirst element of the array.

Return Value

The array with values.

Remarks

Arrays up to 21 elements are supported.

Related

None.

Example

#include <Array.au3>

Dim $avArray
$avArray = _ArrayCreate("JPM", "Holger", "Jon", "Larry", "Jeremy", "Valik", "Cyberslug", "Nutster", "Tylo", "JdeB")

_ArrayDisplay( $avArray, "Array created with _ArrayCreate" )

Exit


Function _ArrayDelete

Function Reference

_ArrayDelete

Deletes the specified element from the given array.

#include <Array.au3>
_ArrayDelete ( $avArray, $iElement )

Parameters

$avArray | The array from which an element is to be deleted.
$iElement | The index of the element to be deleted.

Return Value

Success: | Returns 1 and the original Array is updated.
Failure: | Returns 0 and the original Array.
@Error: | 0 = No error.
 | 1 = $avArray isn't an array.
 | 2 = $avArray has only 1 element in it.

Remarks

If the array passed in has only 1 element, this function returns an empty string.
If the modified array equals the original array, then the original array is returned and @error is set to 2.

Related

_ArrayAdd, _ArrayInsert

Example

#include <Array.au3>

Dim $avArray[10]
$avArray[0] = "JPM"
$avArray[1] = "Holger"
$avArray[2] = "Jon"
$avArray[3] = "Larry"
$avArray[4] = "Jeremy"
$avArray[5] = "Valik"
$avArray[6] = "Cyberslug"
$avArray[7] = "Nutster"
$avArray[8] = "JdeB"
$avArray[9] = "Tylo"
_ArrayDisplay( $avArray, "Whole array" )
_ArrayDelete( $avArray,8)
_ArrayDisplay( $avArray, "Removed entry 8" )


Function _ArrayDisplay

Function Reference

_ArrayDisplay

Displays a 1-dimensional or 2-dimensional array in a ListView .
Options to show only 4000 rows, transpose view, choose alternate separator characters and replacement characters

#include <Array.au3>
_ArrayDisplay ( $ar_2DArray [, $sTitle [, $i_ShowOver4000 [, $i_Transpose [, $GUIDataSeparatorChar [, $GUIDataReplace] ] ] ] ] )

Parameters

$ar_2DArray | Name of Array to display; 1 or 2 dimensional
$sTitle | optional - The new title for Array Display ListView.
$i_ShowOver4000 | optional 0 = Limit number of rows displayed to 4000 for speed - 1 = (default) Display all rows [may slow down over 4000]
$i_Transpose | optional 0 = (default) don't transpose view - 1 = transpose view
$GUIDataSeparatorChar | optional (default="|") change option of character for ListView display [see Opt("GUIDataSeparatorChar", $GUIDataSeparatorChar)]
$GUIDataReplace | optional (default="~") change character to use in items of display if the item contains the separator character

Return Value

Success: | Returns 1.
Failure: | Returns 0.
@Error: | 0 = No error.
 | 1 = $avArray isn't an array.

Remarks

None.

Related

_ArrayToClip

Example

; Ex. #1:
#include <Array.au3>
$asControls = StringSplit(WinGetClassList("", ""), @LF)
_ArrayDisplay($asControls, "Class List of Active Window")

; Ex. #2:
#include <Array.au3>
Dim $arGrid[2][4] = [["Paul", "Jim", "Richard", "Louis"], [485.44, 160.68, 275.16, 320.00]]
_ArrayDisplay($arGrid, "_ArrayDisplay() 2D Test", 1, 1) ; [2D, transposed]

; Ex. #3:
#include <Array.au3>
Dim $avArray[8]
$avArray[0] = 7
$avArray[1] = "Brian"
$avArray[2] = "Jon"
$avArray[3] = "Larry"
$avArray[4] = "Christa"
$avArray[5] = "Rick"
$avArray[6] = "Jack"
$avArray[7] = "Gregory"
_ArrayDisplay($avArray, "_ArrayDisplay() Test")


Function _ArrayInsert

Function Reference

_ArrayInsert

Inserts the a new string at the specified element into the specified array.

#include <Array.au3>
_ArrayInsert ( $avArray, $iElement [, $sValue ] )

Parameters

$avArray | The array in which an element is to be inserted.
$iElement | The index where the element is to be inserted.
$sValue | Optional: String to insert at the specified position.

Return Value

Success: | Returns 1 and updates the original array.
Failure: | Returns 0.
@Error: | 0 = No error.
 | 1 = $avArray isn't an array.

Remarks

None.

Related

_ArrayAdd, _ArrayDelete

Example

#include <Array.au3>

Dim $avArray[10]
$avArray[0] = "JPM"
$avArray[1] = "Holger"
$avArray[2] = "Jon"
$avArray[3] = "Larry"
$avArray[4] = "Jeremy"
$avArray[5] = "Valik"
$avArray[6] = "Cyberslug"
$avArray[7] = "Nutster"
$avArray[8] = "JdeB"
$avArray[9] = "Tylo"
_ArrayDisplay( $avArray, "Whole array" )
_ArrayInsert( $avArray,4,"New")
_ArrayDisplay( $avArray, "Updated Array" )
Exit


Function _ArrayMax

Function Reference

_ArrayMax

Returns the highest value held in an array.

#include <Array.au3>
_ArrayMax ( $avArray [[, $iCompNumeric ], $i_Base ] )

Parameters

$avArray | The array to be scanned.
$iCompNumeric | 0 = Alpha numeric compare 1 = Numeric compare
$i_Base | Optional: Start Array index for sort, normally 0 or 1. default = 0

Return Value

Success: | Returns the highest value in the array.
Failure: | Returns an empty string.
@Error: | 0 = No error.
 | 1 = $avArray isn't an array.

Remarks

None.

Related

_ArrayMaxIndex, _ArrayMin, _ArrayMinIndex

Example

#include <Array.au3>
;
$avArray = StringSplit("4,2,06,8,12,5",",")
;
MsgBox(0,'Max Index String value',_ArrayMaxIndex( $avArray, 0, 1))
MsgBox(0,'Max Index Numeric value',_ArrayMaxIndex( $avArray, 1, 1))
;
MsgBox(0,'Max String value',_ArrayMax( $avArray, 0, 1))
MsgBox(0,'Max Numeric value',_ArrayMax( $avArray, 1, 1))
;
MsgBox(0,'Min Index String value',_ArrayMinIndex( $avArray , 0, 1))
MsgBox(0,'Min Index Numeric value',_ArrayMinIndex( $avArray, 1, 1))
;
MsgBox(0,'Min String value',_ArrayMin( $avArray, 0, 1))
MsgBox(0,'Min Numeric value',_ArrayMin( $avArray, 1, 0))

Exit


Function _ArrayMaxIndex

Function Reference

_ArrayMaxIndex

Returns the index where the highest value occurs in the array.

#include <Array.au3>
_ArrayMaxIndex ( $avArray [[, $iCompNumeric ], $i_Base ] )

Parameters

$avArray | The array to be scanned.
$iCompNumeric | 0 = Alpha numeric compare 1 = Numeric compare
$i_Base | Optional: Start Array index , normally 0 or 1. default = 0

Return Value

Success: | Returns the index of the highest value in the array.
Failure: | Returns an empty string.
@Error: | 0 = No error.
 | 1 = $avArray isn't an array.

Remarks

None.

Related

_ArrayMax, _ArrayMin, _ArrayMinIndex

Example

#include <Array.au3>
;
$avArray = StringSplit("4,2,06,8,12,5",",")
;
MsgBox(0,'Max Index String value',_ArrayMaxIndex( $avArray, 0, 1))
MsgBox(0,'Max Index Numeric value',_ArrayMaxIndex( $avArray, 1, 1))
;
MsgBox(0,'Max String value',_ArrayMax( $avArray, 0, 1))
MsgBox(0,'Max Numeric value',_ArrayMax( $avArray, 1, 1))
;
MsgBox(0,'Min Index String value',_ArrayMinIndex( $avArray , 0, 1))
MsgBox(0,'Min Index Numeric value',_ArrayMinIndex( $avArray, 1, 1))
;
MsgBox(0,'Min String value',_ArrayMin( $avArray, 0, 1))
MsgBox(0,'Min Numeric value',_ArrayMin( $avArray, 1, 0))

Exit


Function _ArrayMin

Function Reference

_ArrayMin

Returns the lowest value held in an array.

#include <Array.au3>
_ArrayMin ( $avArray [[, $iCompNumeric ], $i_Base ] )

Parameters

$avArray | The array to be scanned.
$iCompNumeric | 0 = Alpha numeric compare 1 = Numeric compare
$i_Base | Optional: Start Array index for sort, normally 0 or 1. default = 0

Return Value

Success: | Returns the lowest value in the array.
Failure: | Returns an empty string.
@Error: | 0 = No error.
 | 1 = $avArray isn't an array.

Remarks

None.

Related

_ArrayMax, _ArrayMaxIndex, _ArrayMinIndex

Example

#include <Array.au3>
;
$avArray = StringSplit("4,2,06,8,12,5",",")
;
MsgBox(0,'Max Index String value',_ArrayMaxIndex( $avArray, 0, 1))
MsgBox(0,'Max Index Numeric value',_ArrayMaxIndex( $avArray, 1, 1))
;
MsgBox(0,'Max String value',_ArrayMax( $avArray, 0, 1))
MsgBox(0,'Max Numeric value',_ArrayMax( $avArray, 1, 1))
;
MsgBox(0,'Min Index String value',_ArrayMinIndex( $avArray , 0, 1))
MsgBox(0,'Min Index Numeric value',_ArrayMinIndex( $avArray, 1, 1))
;
MsgBox(0,'Min String value',_ArrayMin( $avArray, 0, 1))
MsgBox(0,'Min Numeric value',_ArrayMin( $avArray, 1, 0))

Exit


Function _ArrayMinIndex

Function Reference

_ArrayMinIndex

Returns the index where the lowest value occurs in the array.

#include <Array.au3>
_ArrayMinIndex ( $avArray [[, $iCompNumeric ], $i_Base ] )

Parameters

$avArray | The array to be scanned.
$iCompNumeric | 0 = Alpha numeric compare 1 = Numeric compare
$i_Base | Optional: Start Array index, normally 0 or 1. default = 0

Return Value

Success: | Returns the index of the lowest value in the array.
Failure: | Returns an empty string.
@Error: | 0 = No error.
 | 1 = $avArray isn't an array.

Remarks

None.

Related

_ArrayMax, _ArrayMaxIndex, _ArrayMin

Example

#include <Array.au3>
;
$avArray = StringSplit("4,2,06,8,12,5",",")
;
MsgBox(0,'Max Index String value',_ArrayMaxIndex( $avArray, 0, 1))
MsgBox(0,'Max Index Numeric value',_ArrayMaxIndex( $avArray, 1, 1))
;
MsgBox(0,'Max String value',_ArrayMax( $avArray, 0, 1))
MsgBox(0,'Max Numeric value',_ArrayMax( $avArray, 1, 1))
;
MsgBox(0,'Min Index String value',_ArrayMinIndex( $avArray , 0, 1))
MsgBox(0,'Min Index Numeric value',_ArrayMinIndex( $avArray, 1, 1))
;
MsgBox(0,'Min String value',_ArrayMin( $avArray, 0, 1))
MsgBox(0,'Min Numeric value',_ArrayMin( $avArray, 1, 0))

Exit


Function _ArrayPop

Function Reference

_ArrayPop

Returns the last element of an array, deleting that element from the array at the same time.

#include <Array.au3>
_ArrayPop ( $avArray )

Parameters

$avArray The array to be decreased.

Return Value

Success: | Returns the value of the last element.
Failure: | Returns an empty string.
@Error: | 0 = No error.
 | 1 = $avArray isn't an array.

Remarks

This function changes the array in place by useing the ByRef keyword in the parameter definition of $avArray. So, not only does it return the last element of the array, but it ALSO changes the array to have 1 less element.

Related

None.

Example

#include <Array.au3>

Dim $avArray[10]
$avArray[0] = "JPM"
$avArray[1] = "Holger"
$avArray[2] = "Jon"
$avArray[3] = "Larry"
$avArray[4] = "Jeremy"
$avArray[5] = "Valik"
$avArray[6] = "Cyberslug"
$avArray[7] = "Nutster"
$avArray[8] = "JdeB"
$avArray[9] = "Tylo"

While UBound($avArray) > 0
MsgBox(0,'',_ArrayPop($avArray))
_ArrayDisplay( $avArray, "Entries left in the array" )
WEnd

Exit


Function _ArrayPush

Function Reference

_ArrayPush

Add new values without increasing array size. Either by inserting at the end the new value and deleting the first one or vice versa.

#include <Array.au3>
_ArrayPush ( ByRef $avArray, $sValue [, $i_Direction = 0 ] )

Parameters

$avArray | Input Array to updated.
$sValue | New value to be added.It can be an array too.
$i_Direction | Optional: 0 = Leftwise slide of values (default) 1 = Rightwise slide of values

Return Value

Success: | Returns 1
Failure: | Returns 0 if $avArray is not an array.
 | -1 if $sValue array size is greater than $avArray size.
 | In both cases @error is set to 1.

Remarks

This function is used for continuous updates of data in array, where in other cases a vast size of array would be created.It keeps all values inside the array -something like History - ,minus the first one or the last one depending on direction chosen.It is similar to Push command in Assembly.

Related

_ArrayPop

Example

#include <Array.au3>

;First Example

Dim $test[5],$var[2],$b=5
$test[0]=0
$test[1]=1
$test[2]=2
$test[3]=3
$test[4]=4

$var[0]=6
$var[1]=7

_ArrayPush($test,$b)
_ArrayDisplay($test,"ArrayUpdate Test") ; The values now are : 1,2,3,4,5

_ArrayPush($test,$var)
_ArrayDisplay($test,"ArrayUpdate Test") ; The values now are : 3,4,5,6,7

;Second Example(not working)
Dim $Monitor[5],$Messages=""
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
;;;;
EndSelect
_ArrayPush($Monitor,$msg)
WEnd

For $i = 0 to 4
$Messages&=$monitor[$i] & ","
Next

MsgBox(0,"Monitoring Test"," The last 5 GUI Messages were : " & $Messages)


Function _ArrayReverse

Function Reference

_ArrayReverse

Takes the given array and reverses the order in which the elements appear in the array.

#Include <Array.au3>
_ArrayReverse ( ByRef $avArray [, $i_Base = 0 [, $i_UBound = 0 ]] )

Parameters

$avArray | The array to be reversed.
$i_Base | Optional: Array base
$i_UBound | Optional: Upper bound of Array

Return Value

Success: | Returns 1
Failure: | Returns 0 if non array passed for array param.

Remarks

None

Related

_ArraySwap

Example

#include <Array.au3>
Dim $avArray[10]
$avArray[0] = "JPM"
$avArray[1] = "Holger"
$avArray[2] = "Jon"
$avArray[3] = "Larry"
$avArray[4] = "Jeremy"
$avArray[5] = "Valik"
$avArray[6] = "Cyberslug"
$avArray[7] = "Nutster"
$avArray[8] = "Tylo"
$avArray[9] = "JdeB"

_ArrayDisplay( $avArray, "Normal" )
_ArrayReverse( $avArray)
_ArrayDisplay( $avArray, "Reversed" )

; Example Reverse Array created with StringSplit.
$avArray = StringSplit("0,1,2,3,4,5,6,7,8,9,10,11,12",",")
_ArrayDisplay( $avArray, "Normal" )
_ArrayReverse( $avArray, 1) ; added the 1 as second parameter
_ArrayDisplay( $avArray, "Reversed" )

Exit


Function _ArraySearch

Function Reference

_ArraySearch

Finds an entry within an one-dimensional array. (Similar to _ArrayBinarySearch() except the array does not need to be sorted.)

#include <Array.au3>
_ArraySearch ( $avArray, $vWhat2Find, $iStart = 0, $iEnd = 0, $iCaseSense = 0, $fPartialSearch = False )

Parameters

$avArray | The array to search
$vWhat2Find | What to search $avArray for
$iStart (Optional) | Start array index for search, normally set to 0 or 1. If omitted it is set to 0
$iEnd (Optional) | End array index for search. If omitted or set to 0 it is set to Ubound($AvArray)
$iCaseSense (Optional) | If set to 1 then search is case sensitive
$fPartialSearch (Optional) | If set to True then executes a partial search. If omitted it is set to False

Return Value

Success: | The first found instance of $vWhat2Find in $avArray
Failure: | Returns -1 and sets @Error on Errors.
@Error: | 1 $avArray is not an array
 | 2 $iStart is greater than UBound($AvArray)-1
 | 3 $iEnd is greater than UBound($AvArray)-1
 | 4 $iStart is greater than $iEnd
 | 5 $iCaseSense was invalid. (Must be 0 or 1)
 | 6 $vWhat2Find was not found in $avArray

Remarks

This function might be slower than _ArrayBinarySearch() but is useful when the array's order can't be altered.

Related

_ArrayBinarySearch

Example

#Include<Array.au3>
Dim $Array[6]
$Array[0] = "String0|SubString0"
$Array[1] = "String1|SubString1"
$Array[2] = "String2|SubString2"
$Array[3] = "String3|SubString3"
$Array[4] = "String4|SubString4"
$Array[5] = "String5|SubString5"

$Input = InputBox("ArraySearch Demo", "String To Find?")
If @error Then Exit

$Pos = _ArraySearch ($Array, $Input, 0, 0, 0, True)
Select
Case $Pos = -1
MsgBox(0, "Not Found", '"' & $Input & '" was not found in the array.')
Case Else
MsgBox(0, "Found", '"' & $Input & '" was found in the array at pos ' & $Pos & ".")
EndSelect


Function _ArraySort

Function Reference

_ArraySort

Sort a mutiple dimensional Array.

#include <Array.au3>
_ArraySort ( ByRef $a_Array [, $i_Descending [, $i_Base=0 [, $i_Ubound=0 [, $i_Dim=1 [, $i_SortIndex=0 ]]]]] )

Parameters

$a_Array | Input Array to be sorted.
$i_Descending | Optional: 1=Sort Descending else Ascending.
$i_Base | Optional: Start Array index for sort, normally set to 0 or 1.
$i_Ubound | Optional: Set the UBound for sorting which will only sort the defined number of entries in stead of the whole array.
$i_Dim | Optional: Number of occurences in the second dimension eg $A[100] = 0, $A[100][2] = 2, $A[100][5] = 5
$i_SortIndex | Optional: The index to Sort on.

Return Value

None.

Remarks

This sort functions can handle 1 or 2 dimension arrays.

Related

None.

Example

#include <Array.au3>

Dim $avArray[10]
$avArray[0] = "JPM"
$avArray[1] = "Holger"
$avArray[2] = "Jon"
$avArray[3] = "Larry"
$avArray[4] = "Jeremy"
$avArray[5] = "Valik"
$avArray[6] = "Cyberslug"
$avArray[7] = "Nutster"
$avArray[8] = "Tylo"
$avArray[9] = "JdeB"

_ArrayDisplay( $avArray, "Unsorted" )
_ArraySort( $avArray)
_ArrayDisplay( $avArray, "Sort Ascending" )
_ArraySort( $avArray,1)
_ArrayDisplay( $avArray, "Sort Decending" )

; Example sort Array created with StringSplit.
$avArray = StringSplit("b,d,c,w,a,e,s,r,x,q",",")
_ArrayDisplay( $avArray, "UnSorted" )
_ArraySort( $avArray,0,1,5) ; sort first 5 entries
_ArrayDisplay( $avArray, "Sort first 5 entries" )
_ArraySort( $avArray,0,1) ; sort and start at 1.. skip array[0]
_ArrayDisplay( $avArray, "Sorted starting at 1" )
_ArraySort( $avArray,1,1) ; sort and start at 1.. skip array[0]
_ArrayDisplay( $avArray, "Sorted Desc starting at 1" )

; Demonstration difference Alpha-numeric and Numeric sorting
Dim $avArray = StringSplit("2|4|7|1|-9|5","|")
_ArrayDisplay( $avArray, "Unsorted" )
_ArraySort( $avArray,1,1)
_ArrayDisplay( $avArray, "Alpha numeric Sorted Descending" )
;Convert Array entries to numeric values
For $x = 1 To UBound($avArray) -1
$avArray[$x] = Number($avArray[$x])
Next
_ArraySort( $avArray,1,1)
_ArrayDisplay( $avArray, "Numeric Sorted Descending" )
Exit


Function _ArraySwap

Function Reference

_ArraySwap

Swaps two elements of an array.

#include <Array.au3>
_ArraySwap ( $sVector1, $sVector2 )

Parameters

$sVector1 | First element in the array to be swapped.
$sVector2 | Second element in the array to be swapped.

Return Value

None.

Remarks

This function swaps the 2 elements in place (they're passed by reference) and so don't do any error checking or returning of values.

Related

_ArrayReverse

Example

#include <Array.au3>

Dim $asArray[2]

$asArray[0] = "World!"
$asArray[1] = "Hello"

_ArrayDisplay( $asArray, "_ArraySwap() - BEFORE" )
_ArraySwap( $asArray[0], $asArray[1] )
_ArrayDisplay( $asArray, "_ArraySwap() - AFTER" )
Exit


Function _ArrayToClip

Function Reference

_ArrayToClip

Sends the contents of an array to the clipboard.

#include <Array.au3>
_ArrayToClip ( $avArray, $i_Base = 0 )

Parameters

$avArray | The array to be sent to the clipboard.
$i_Base | Optional: Start Array index for sort, normally set to 0 or 1.

Return Value

Success: | Returns 1.
Failure: | Returns 0.
@Error: | 0 = No error.
 | 1 = The clipboard was cleared.

Remarks

None.

Related

_ArrayDisplay, _ArrayToString, StringSplit

Example

#include <Array.au3>
$asArray = StringSplit("a,b,c,d,e,f,g,h,i",",")
$iRetCode = _ArrayToClip( $asArray, 1 )
MsgBox( 4096, "_ArrayToClip() Test", ClipGet() )
Exit


Function _ArrayToString

Function Reference

_ArrayToString

Places the elements of an array into a single string, separated by the specified delimiter.

#include <Array.au3>
_ArrayToString ( $avArray, $sDelim [[, $iStart ], $iEnd ] )

Parameters

$avArray | The array to be converted into a string.
$sDelim | The delimiter to separate each element with.
$iStart | Optional (default to 0): An integer that specifies the element to start at in the array.
$iEnd | Optional (Default to Ubound): An integer that specifies the element to end at in the array.

Return Value

Success: | Returns a delimited string containing all elements within the range specified.
Failure: | Returns an empty string.
@Error: | 0 = No error.
 | 1 = $avArray isn't an array.
 | 2 = $iStart or $iEnd are less than 0 or $iStart is greater than $iEnd

Remarks

This function is the opposite of the StringSplit function with the extension of being able to take a subset of all of the elements and placing just that subset into the string.

This function only accepts a 1 dimensional array.

If both $iStart and $iEnd = -1 or the Default keyword, then the entire array will be converted to a string.

Related

_ArrayToClip, _FileReadToArray, StringSplit

Example

#include <Array.au3>

Dim $avArray[11], $I = 0

; Populate test array.
For $I = 0 to UBound( $avArray ) - 1
$avArray[$I] = Int( Random( -20000, 20000 ) )
Next

_ArrayDisplay( $avArray, "_ArrayToString() Test" )

Dim $sArrayString = _ArrayToString( $avArray,@TAB, 1, 7 )
MsgBox( 4096, "_ArrayToString() Test", $sArrayString )
Exit


Function _ArrayTrim

Function Reference

_ArrayTrim

Trims all elements in an array a certain number of characters.

#include <Array.au3>
_ArrayTrim ( $aArray, $iTrimNum [, $iTrimDirection [, $iBase [, $iUbound ]]] )

Parameters

$aArray | The array to trim the items of.
$iTrimNum | The amount of characters to trim.
$iTrimDirection | Optional: Default=0. 0 to trim left, 1 to trim right
$iBase | Optional: Start Array index for sort, normally set to 0 or 1.
$iUbound | Optional: Set the UBound for trimming which will only trim the defined number of entries instead of the whole array.

Return Value

Success: | Returns the new trimmed array.
Failure: | Returns the array unchanged.
@Error: | 0 = No error.
 | 1 = If invalid array
 | 2 = Invalid base boundry parameter
 | 3 = Invalid end boundry parameter
 | 4 = If $iTrimDirection is not a zero or a one

Remarks

None.

Related

None.

Example

#include <Array.au3>

Dim $avArray[5]
$avArray[0] = "ab"
$avArray[1] = "bc"
$avArray[2] = "cd"
$avArray[3] = "de"
$avArray[4] = "ef"

$aNewArray = _ArrayTrim( $avArray, 1, 1,1,3)
_ArrayDisplay($aNewArray,"demo _ArrayTrim")
Exit

;The new array in order should now be "a", "b" , "c" , "d", "e".


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: Color Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_ColorGetBlue | Returns the blue component of a given color.
_ColorGetGreen | Returns the green component of a given color.
_ColorGetRed | Returns the red component of a given color.


Function _ColorGetBlue

Function Reference

_ColorGetBlue

Returns the blue component of a given color.

#include <Color.au3>
_ColorGetBlue ( $nColor )

Parameters

$nColor The RGB color to work with (hexadecimal code).

Return Value

Returns the component color in the range 0-255.

Remarks

None.

Related

_ColorGetRed, _ColorGetGreen

Example

#include <Color.au3>

$iBlueColor = _ColorGetBlue( 0x8080ff )
MsgBox( 4096, "AutoIt", $iBlueColor )


Function _ColorGetGreen

Function Reference

_ColorGetGreen

Returns the green component of a given color.

#include <Color.au3>
_ColorGetGreen ( $nColor )

Parameters

$nColor The RGB color to work with (hexadecimal code).

Return Value

Returns the component color in the range 0-255.

Remarks

None.

Related

_ColorGetRed, _ColorGetBlue

Example

#include <Color.au3>

$iGreenColor = _ColorGetGreen( 0x8080ff )
MsgBox( 4096, "AutoIt", $iGreenColor )


Function _ColorGetRed

Function Reference

_ColorGetRed

Returns the red component of a given color.

#include <Color.au3>
_ColorGetRed ( $nColor )

Parameters

$nColor The RGB color to work with (hexadecimal code).

Return Value

Returns the component color in the range 0-255.

Remarks

None.

Related

_ColorGetGreen, _ColorGetBlue

Example

#include <Color.au3>

$iRedColor = _ColorGetRed( 0x8080ff )
MsgBox( 4096, "AutoIt", $iRedColor )


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: Date Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_DateAdd | Calculates a new date based on a given date and add an interval.
_DateDayOfWeek | Returns the name of the weekday, based on the specified day.
_DateDaysInMonth | Returns the number of days in a month, based on the specified month and year.
_DateDiff | Returns the difference between 2 dates, expressed in the type requested.
_DateIsLeapYear | Checks a given year to see if it is a leap year.
_DateIsValid | Checks the given date to determine if it is a valid date.
_DateTimeFormat | Returns the date in the PC's regional settings format.
_DateTimeSplit | Split a string containing Date and Time into two separate Arrays.
_DateToDayOfWeek | Returns the weekdaynumber for a given date.
_DateToDayOfWeekISO | Returns the ISO weekdaynumber for a given date.
_DateToDayValue | Returns the daynumber since since noon 4713 BC January 1 for a given Gregorian date.
_DateToMonth | Returns the name of the Month, based on the specified month number.
_DayValueToDate | Add the given days since noon 4713 BC January 1 and returns the Gregorian date.
_Now | Returns the current Date and Time in PC's format.
_NowCalc | Returns the current Date and Time in format YYYY/MM/DD HH:MM:SS for use in date calculations.
_NowCalcDate | Returns the current Date in format YYYY/MM/DD.
_NowDate | Returns the current Date in the Pc's format.
_NowTime | Returns the current Time in requested format.
_SetDate | Sets the current date of the system
_SetTime | Sets the current time of the system
_TicksToTime | Converts the specified tick amount to hours, minutes and seconds.
_TimeToTicks | Converts the specified hours, minutes, and seconds to ticks.
_WeekNumberISO | Calculate the weeknumber of a given date.


Function _DateAdd

Function Reference

_DateAdd

Calculates a new date based on a given date and add an interval.

#include <Date.au3>
_DateAdd ( $sType, $iValToAdd, $sDate )

Parameters

$sType | D = Add number of days to the given date M = Add number of months to the given date Y = Add number of years to the given date w = Add number of weeks to the given date h = Add number of hours to the given date n = Add number of minutes to the given date s = Add number of seconds to the given date
$iValToAdd | number to be added
$sDate | Input date in the format "YYYY/MM/DD[ HH:MM:SS]"

Return Value

Success: | Newly calculated date.
Failure: | 0
@Error: | 0 = No error.
 | 1 = Invalid $sType
 | 2 = Invalid $iValToAdd
 | 3 = Invalid $sDate

Remarks

The function will not return an invalid date.
e.g When 3 months are added to '2004/1/31' then the result will be 2004/04/30

Related

_DateDiff

Example

#include <Date.au3>

; Add 5 days to today
$sNewDate = _DateAdd( 'd',5, _NowCalcDate())
MsgBox( 4096, "", "Today + 5 days:" & $sNewDate )

; Subtract 2 weeks from today
$sNewDate = _DateAdd( 'w',-2, _NowCalcDate())
MsgBox( 4096, "", "Today minus 2 weeks: " & $sNewDate )

; Add 15 minutes to current time
$sNewDate = _DateAdd( 'n',15, _NowCalc())
MsgBox( 4096, "", "Current time +15 minutes: " & $sNewDate )

; Calculated eventlogdate which returns second since 1970/01/01 00:00:00
$sNewDate = _DateAdd( 's',1087497645, "1970/01/01 00:00:00")
MsgBox( 4096, "", "Date: " & $sNewDate )


Function _DateDayOfWeek

Function Reference

_DateDayOfWeek

Returns the name of the weekday, based on the specified day.

#include <Date.au3>
_DateDayOfWeek ( $iDayNum [, $iFormat] )

Parameters

$iDayNum | Day number (1 = Sunday, 7 = Saturday).
$iFormat | Optional - Format: 0 = Long name of the weekday. 1 = Abbreviated name of the weekday.

Return Value

Success: | Returns the name of the given weekday.
Failure: | Returns an empty string.
@Error: | 0 = No error.
 | 1 = Invalid day number or format.

Remarks

This function returns English day names only.

Related

_DateDaysInMonth

Example

#include <Date.au3>

; Retrieve the long name
$sLongDayName = _DateDayOfWeek( @WDAY )

; Retrieve the abbreviated name
$sShortDayName = _DateDayOfWeek( @WDAY, 1 )

MsgBox( 4096, "Day of Week", "Today is: " & $sLongDayName & " (" & $sShortDayName & ")" )


Function _DateDaysInMonth

Function Reference

_DateDaysInMonth

Returns the number of days in a month, based on the specified month and year.

#include <Date.au3>
_DateDaysInMonth ( $iYear, $iMonthNum )

Parameters

$iYear | 4-digit year.
$iMonthNum | Month number (1 = January, 12 = December).

Return Value

Success: | Returns the number of days in the month.
Failure: | Returns 0.
@Error: | 0 = No error.
 | 1 = Invalid month number or year.

Remarks

None.

Related

None.

Example

#include <Date.au3>

$iDays = _DateDaysInMonth( @YEAR,@MON )
MsgBox( 4096, "Days in Month", "This month has " & String( $iDays ) & " days in it." )


Function _DateDiff

Function Reference

_DateDiff

Returns the difference between 2 dates, expressed in the type requested.

#include <Date.au3>
_DateDiff ( $sType, $sStartDate, $sEndDate )

Parameters

$sType | D = Difference in days between the given dates M = Difference in months between the given dates Y = Difference in years between the given dates w = Difference in Weeks between the given dates h = Difference in hours between the given dates n = Difference in minutes between the given dates s = Difference in seconds between the given dates
$sStartDate | Input date in the format "YYYY/MM/DD[ HH:MM:SS]"
$sEndDate | Input End date in the format "YYYY/MM/DD[ HH:MM:SS]"

Return Value

Success: | Difference between the 2 dates.
Failure: | 0
@Error: | 0 = No error.
 | 1 = Invalid $sType
 | 2 = Invalid $sStartDate
 | 3 = Invalid $sEndDate

Remarks

None.

Related

_DateAdd

Example

#include <Date.au3>

; Calculated the number of seconds since EPOCH (1970/01/01 00:00:00)
$iDateCalc = _DateDiff( 's',"1970/01/01 00:00:00",_NowCalc())
MsgBox( 4096, "", "Number of seconds since EPOCH: " & $iDateCalc )

; Calculated the number of Hours this year
$iDateCalc = _DateDiff( 'h',@YEAR & "/01/01 00:00:00",_NowCalc())
MsgBox( 4096, "", "Number of Hours this year: " & $iDateCalc )


Function _DateIsLeapYear

Function Reference

_DateIsLeapYear

Checks a given year to see if it is a leap year.

#include <Date.au3>
_DateIsLeapYear ( $iYear )

Parameters

$iYear The 4-digit year to check.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if the year is not a leap year.
@Error: | 0 = No error.
 | 1 = Invalid year.

Remarks

None.

Related

None.

Example

#include <Date.au3>

If _DateIsLeapYear( @YEAR ) Then
MsgBox( 4096, "Leap Year", "This year is a leap year." )
Else
MsgBox( 4096, "Leap Year", "This year is not a leap year." )
EndIf


Function _DateIsValid

Function Reference

_DateIsValid

Checks the given date to determine if it is a valid date.

#include <Date.au3>
_DateIsValid ( $sDate )

Parameters

$sDate The date to be checked.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if the specified date is not valid.

Remarks

This function takes a date input in one of the following formats:
"yyyy/mm/dd[ hh:mm[:ss]]" or "yyyy/mm/dd[Thh:mm[:ss]]"
"yyyy-mm-dd[ hh:mm[:ss]]" or "yyyy-mm-dd[Thh:mm[:ss]]"
"yyyy.mm.dd[ hh:mm[:ss]]" or "yyyy.mm.dd[Thh:mm[:ss]]"

Related

None.

Example

#include <Date.au3>

$sDate = @YEAR & "/" & @MON & "/" & @MDAY

If _DateIsValid( $sDate ) Then
MsgBox( 4096, "Valid Date", "The specified date is valid." )
Else
MsgBox( 4096, "Valid Date", "The specified date is invalid." )
EndIf


Function _DateTimeFormat

Function Reference

_DateTimeFormat

Returns the date in the PC's regional settings format.

#Include <date.au3>
_DateTimeFormat ( $sDate, $sType)

Parameters

$sDate | Input date in the format "YYYY/MM/DD[ HH:MM:SS]"
$sType | 0 = Display a date and/or time. If there is a date part, display it as a short date. If there is a time part, display it as a long time. If present, both parts are displayed. 1 = Display a date using the long date format specified in your computer's regional settings. 2 = Display a date using the short date format specified in your computer's regional settings. 3 = Display a time using the time format specified in your computer's regional settings. 4 = Display a time using the 24-hour format (hh:mm). 5 = Display a time using the 24-hour format (hh:mm:ss).
$iValToAdd | number to be added

Return Value

Success: | Returns date in proper format.
Failure: | 0
@Error: | 0 = No error.
 | 1 = Invalid $sDate
 | 2 = Invalid $sType

Remarks

None.

Related

None.

Example

#include <Date.au3>

; Show current date/time in the pc's format
MsgBox( 4096, "Pc Long format", _DateTimeFormat( _NowCalc(),1))
MsgBox( 4096, "Pc Short format", _DateTimeFormat( _NowCalc(),2))


Function _DateTimeSplit

Function Reference

_DateTimeSplit

Split a string containing Date and Time into two separate Arrays.

#include <date.au3>
_DateTimeSplit ( $sDate, ByRef $asDatePart, ByRef $iTimePart )

Parameters

$sDate | Any of these formats: "yyyy/mm/dd[ hh:mm[:ss]]" "yyyy/mm/dd[Thh:mm[:ss]]" "yyyy-mm-dd[ hh:mm[:ss]]" "yyyy-mm-dd[Thh:mm[:ss]]" "yyyy.mm.dd[ hh:mm[:ss]]" "yyyy.mm.dd[Thh:mm[:ss]]"
$asDatePart | array that contains the Date. $asDatePart[0] number of values returned
$asTimePart | array that contains the Time. $asTimePart[0] number of values returned

Return Value

Success: | Date and Time into two separate Arrays.
Failure: | 0
@Error: | 0 = No error.
 | 1 = Invalid Input Date

Remarks

None.

Related

_DayValueToDate, _DateAdd, _DateDiff

Example

#include <Date.au3>

Dim $MyDate
Dim $MyTime
_DateTimeSplit("2005/01/01 14:30",$MyDate,$MyTime)

For $x = 1 to $MyDate[0]
MsgBox(0,$x,$MyDate[$x])
Next
For $x = 1 to $MyTime[0]
MsgBox(0,$x,$MyTime[$x])
Next


Function _DateToDayOfWeek

Function Reference

_DateToDayOfWeek

Returns the weekdaynumber for a given date.

#include <date.au3>
_DateToDayOfWeek ( $iYear, $iMonth, $iDay )

Parameters

$iYear | A valid year in format YYYY
$iMonth | A valid month in format MM
$iDay | A valid day in format DD

Return Value

Success: | Returns Day of the Week Range is 1 to 7 where 1=Sunday.
Failure: | 0
@Error: | 0 = No error.
 | 1 = Invalid Input Date

Remarks

None.

Related

_DateToDayOfWeekISO, _DateDayOfWeek, _DayValueToDate, _DateAdd, _DateDiff

Example

#include <Date.au3>

; Week day number for a given date
$iWeekday = _DateToDayOfWeek (@YEAR, @MON, @MDAY)
; Should be equal to @Wday
MsgBox(4096, "", "Todays WeekdayNumber is: " & $iWeekDay)
MsgBox(4096, "", "Today is a : " & _DateDayOfWeek($iWeekDay))


Function _DateToDayOfWeekISO

Function Reference

_DateToDayOfWeekISO

Returns the ISO weekdaynumber for a given date.

#include <date.au3>
_DateToDayOfWeekISO ( $iYear, $iMonth, $iDay )

Parameters

$iYear | A valid year in format YYYY
$iMonth | A valid month in format MM
$iDay | A valid day in format DD

Return Value

Success: | Returns Day of the Week Range is 0 to 6 where 0=Monday.
Failure: | 0
@Error: | 0 = No error.
 | 1 = Invalid Input Date

Remarks

None.

Related

_DateToDayOfWeek, _DateDayOfWeek, _DayValueToDate, _DateAdd, _DateDiff

Example

#include <Date.au3>
; ISO Week day number for a given date 0=Monday - 6=Sunday
$iWeekday = _DateToDayOfWeekISO (@YEAR, @MON, @MDAY)
; NOT equal to @Wday
MsgBox(4096, "", "Todays ISO WeekdayNumber is: " & $iWeekDay)


Function _DateToDayValue

Function Reference

_DateToDayValue

Returns the daynumber since since noon 4713 BC January 1 for a given Gregorian date.

#include <date.au3>
_DateToDayValue ( $iYear, $iMonth, $iDay )

Parameters

$iYear | A valid year in format YYYY
$iMonth | A valid month in format MM
$iDay | A valid day in format DD

Return Value

Success: | Returns the Juliandate (days since noon 4713 BC January 1)
Failure: | 0
@Error: | 0 = No error.
 | 1 = Invalid Input Date

Remarks

None.

Related

_DayValueToDate, _DateAdd, _DateDiff

Example

#include <Date.au3>

; Julian date of today.
$sJulDate = _DateToDayValue (@YEAR, @MON, @MDAY)
MsgBox(4096, "", "Todays Julian date is: " & $sJulDate)

; 14 days ago calculation.
Dim $Y, $M, $D
$sJulDate = _DayValueToDate ($sJulDate-14, $Y, $M, $D)
MsgBox(4096, "", "14 days ago:" & $M & "/" & $D & "/" & $Y)


Function _DateToMonth

Function Reference

_DateToMonth

Returns the name of the Month, based on the specified month number.

#include <Date.au3>
_DateDayOfWeek ( $iMonthNum [, $iFormat] )

Parameters

$iMonthNum | Month number (1 = January, 12 = December).
$iFormat | Optional - Format: 0 = Long name of the Month. 1 = Abbreviated name of the Month.

Return Value

Success: | Returns the name of the given Month.
Failure: | Returns an empty string.
@Error: | 0 = No error.
 | 1 = Invalid month number or format.

Remarks

This function returns English day names only.

Related

Example

#include <Date.au3>

; Retrieve the long name
$sLongMonthName = _DateToMonth(@MON)

; Retrieve the abbreviated name
$sShortMonthName = _DateToMonth(@MON, 1)

MsgBox(4096, "Month of Year", "The month is: " & $sLongMonthName & " (" & $sShortMonthName & ")")


Function _DayValueToDate

Function Reference

_DayValueToDate

Add the given days since noon 4713 BC January 1 and returns the Gregorian date.

#include <Date.au3>
_DayValueToDate ($iJulianDate, ByRef $iYear, ByRef $iMonth, ByRef $iDay)

Parameters

$iJulianDate | A valid number of days.
$iYear | will return the year in format YYYY
$iMonth | will return the month in format MM
$iDay | will return the day in format DD

Return Value

Success: | Returns the date calculate
Failure: | 0
@Error: | 0 = No error.
 | 1 = Invalid Input number of days

Remarks

None.

Related

_DateToDayValue, _DateAdd, _DateDiff

Example

#include <Date.au3>

; Julian date of today.
$sJulDate = _DateToDayValue (@YEAR, @MON, @MDAY)
MsgBox(4096, "", "Todays Julian date is: " & $sJulDate)

; 14 days ago calculation.
Dim $Y, $M, $D
$sJulDate = _DayValueToDate ($sJulDate-14, $Y, $M, $D)
MsgBox(4096, "", "14 days ago:" & $M & "/" & $D & "/" & $Y & " (" & $sJulDate & ")")


Function _Now

Function Reference

_Now

Returns the current Date and Time in PC's format.

#Include <Date.au3>
_Now ( )

Parameters

None.

Return Value

Returns the current Date and Time in PC's format

Remarks

If Date format isn't found in the registry it returns the date in the mm/dd/yyyy format.
If Time format isn't found in the registry it returns the time in the hh:mm:ss format.

Related

None.

Example

#include <Date.au3>

MsgBox( 4096, "", "Todays date/Time: " & _Now() )


Function _NowCalc

Function Reference

_NowCalc

Returns the current Date and Time in format YYYY/MM/DD HH:MM:SS for use in date calculations.

#Include <Date.au3>
_NowCalc ( )

Parameters

None.

Return Value

Returns the current Date and Time in format YYYY/MM/DD HH:MM:SS

Remarks

None.

Related

None.

Example

#include <Date.au3>

; Calculated the number of seconds since EPOCH (1970/01/01 00:00:00)
$iDateCalc = _DateDiff( 's',"1970/01/01 00:00:00",_NowCalc())
MsgBox( 4096, "", "Number of seconds since EPOCH: " & $iDateCalc )

; Calculated the number of Hours this year
$iDateCalc = _DateDiff( 'h',@YEAR & "/01/01 00:00:00",_NowCalc())
MsgBox( 4096, "", "Number of Hours this year: " & $iDateCalc )


Function _NowCalcDate

Function Reference

_NowCalcDate

Returns the current Date in format YYYY/MM/DD.

#Include <Date.au3>
_NowCalcDate ( )

Parameters

None.

Return Value

Returns the current Date in format YYYY/MM/DD

Remarks

None.

Related

None.

Example

#include <Date.au3>
$Msg = "Test record"
FileWriteLine("Pgm.log",_NowCalcDate() & " :" & $Msg )


Function _NowDate

Function Reference

_NowDate

Returns the current Date in the Pc's format.

#Include <date.au3>
_NowDate ( )

Parameters

None.

Return Value

Returns the current Date in the Pc's format.

Remarks

If Date format isn't found in the registry it returns the date in the mm/dd/yyyy format.

Related

_DateTimeFormat, _Now, _NowCalc, _NowCalcDate, _NowTime

Example

#include <Date.au3>
MsgBox(0,'',"The Date is:" & _NowDate())


Function _NowTime

Function Reference

_NowTime

Returns the current Time in requested format.

#Include <Date.au3>
_NowTime ( [$sType] )

Parameters

$sType
Default: 3 = Display a time using the time format specified in your computer's regional settings.
4 = Display a time using the 24-hour format (hh:mm).
5 = Display a time using the 24-hour format (hh:mm:ss).

Return Value

Returns the current Time in PC's time format.

Remarks

If Time format isn't found in the registry it returns the time in the hh:mm:ss format.

Related

_DateTimeFormat, _Now, _NowDate, _NowCalc, _NowCalcDate

Example

#include <Date.au3>
MsgBox(0,'',"The time is:" & _NowTime())


Function _SetDate

Function Reference

_SetDate

Sets the current date of the system

#include <Date.au3>
_SetDate ( $iDay [, $iMonth=0 [, $iYear=0 ]] )

Parameters

$iDay | Day of the month. Values: 1-31
$iMonth | Optional: month. Values: 1-12
$iYear | Optional: year. Values: > 0 (windows might restrict this further!!)

Return Value

Success: | 1
Failure: | 0
@Error: | 0 = No error.
 | 1 = Failure
@extended | GetLastError() Error code(s): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/system_error_codes.asp

Remarks

If the optional parameters (iMonth,iYear) are NOT defined, the function will not change the current value!

Related

_SetTime

Example

#include <Date.au3>

_SetDate(20) ; Set the current date to 20-xx-xxxx
_SetDate(20,10) ; Set the current date to 20-10-xxxx
_SetDate(20,10,2004) ; Set the current date to 20-10-2004


Function _SetTime

Function Reference

_SetTime

Sets the current time of the system

#include <Date.au3>
_SetTime ( $iHour, $iMinute [, $iSecond=0 ] )

Parameters

$iHour | the hour. Values: 0-23
$iMinute | the minute. Values: 0-59
$iSecond | Optional: the seconds. Values: 0-59

Return Value

Success: | 1
Failure: | 0
@Error: | 0 = No error.
 | 1 = Failure
@extended | GetLastError() Error code(s): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/system_error_codes.asp

Remarks

If the optional parameter (iSecond) is NOT defined, the function will not change the current value!

Related

_SetDate

Example

#include <Date.au3>

_SetTime(20,15) ; Set time to 20:15
_SetTime(20,15,30) ; Set time to 20:15:30


Function _TicksToTime

Function Reference

_TicksToTime

Converts the specified tick amount to hours, minutes and seconds.

#Include <Date.au3>
_TicksToTime ( $iTicks, $iHours, $iMins, $iSecs )

Parameters

$iTicks | Tick amount.
$iHours | Variable to store the hours.
$iMins | Variable to store the minutes.
$iSecs | Variable to store the seconds.

Return Value

Success: | Returns 1.
Failure: | Returns 0.
@Error: | 0 = No error.
 | 1 = $iTicks isn't an integer.

Remarks

None.

Related

_TimeToTicks

Example

; *** Demo to show a timer window
#include <GUIConstants.au3>
#include <Date.au3>
opt("TrayIconDebug",1)
Global $Secs, $Mins, $Hour, $Time
;Create GUI
GUICreate("Timer",120, 50)
GUICtrlCreateLabel("00:00:00", 10,10)
GUISetState()
;Start timer
$timer = TimerInit()
AdlibEnable("Timer", 50)
;
While 1
;FileWriteLine("debug.log",@min & ":" & @sec & " ==> before")
$msg = GUIGetMsg()
;FileWriteLine("debug.log",@min & ":" & @sec & " ==> after")
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
EndSelect
Wend
;
Func Timer()
_TicksToTime(Int(TimerDiff($timer)), $Hour, $Mins, $Secs )
Local $sTime = $Time ; save current time to be able to test and avoid flicker..
$Time = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
If $sTime <> $Time Then ControlSetText("Timer", "", "Static1", $Time)
EndFunc ;==>Timer


Function _TimeToTicks

Function Reference

_TimeToTicks

Converts the specified hours, minutes, and seconds to ticks.

#include <Date.au3>
_TimeToTicks ( [ $iHours = @Hour [, $iMins = @Min [, $iSecs = @Sec ]]] )

Parameters

$iHours | The hours.
$iMins | The minutes.
$iSecs | The seconds.

Return Value

Success: | Returns the number of ticks.
Failure: | Returns 0.
@Error: | 0 = No error.
 | 1 = The specified hours, minutes, or seconds are not valid.

Remarks

None.

Related

_TicksToTime

Example

#include <Date.au3>
Global $Sec, $Min, $Hour, $Time
; calculate with time
$StartTicks = _TimeToTicks(@HOUR,@MIN,@SEC)
; calculate 45 minutes later
$EndTicks = $StartTicks + 45 * 60 * 1000
_TicksToTime($EndTicks,$Hour,$Min,$Sec)
MsgBox(262144,'' , 'New Time:' & $Hour & ":" & $Min & ":" & $Sec)


Function _WeekNumberISO

Function Reference

_WeekNumberISO

Calculate the weeknumber of a given date.

#include <Date.au3>
_WeekNumberISO ( $iYear=@YEAR, $iMonth=@MON, $iDay=@MDAY )

Parameters

$iYear | Year value (default = current year)
$iMonth | Month value (default = current month)
$iDay | Day value (default = current day)
$iWeekstart | Week starts from Sunday (0, default) or Monday (1)

Return Value

Success: | Returns week number of given date
Failure: | -1
@Error: | 0 = No error.
 | 1 = faulty parameters values
 | 99 = On non-acceptable weekstart value

Remarks

None.

Related

None.

Example

#include <Date.au3>

MsgBox(0,"Todays weeknumber","Todays weeknumber is " & _WeekNumberISO())


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: File Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_FileCountLines | Returns the number of lines in the specified file.
_FileCreate | Creates or zero's out the length of the file specified.
_FileListToArray | lists files and\or folders in a specified path (Similar to using Dir with the /B Switch)
_FilePrint | Prints a plain text file.
_FileReadToArray | Reads the specified file into an array.
_FileWriteFromArray | Writes Array records to the specified file.
_FileWriteLog | Writes current date,time and the specified text to a log file.
_FileWriteToLine | Writes text to a specific line in a file.
_PathFull | Creates a path based on the relative path you provide. The newly created absolute path is returned
_PathMake | Creates a path from drive, directory, file name and file extension parts. Not all parts must be passed.
_PathSplit | Splits a path into the drive, directory, file name and file extension parts. An empty string is set if a part is missing.
_ReplaceStringInFile | Replaces a string with another string in the given text file (binary won't work!)
_TempFile | Generate a name for a temporary file. The file is guaranteed not to exist yet.


Function _FileCountLines

Function Reference

_FileCountLines

Returns the number of lines in the specified file.

#include <File.au3>
_FileCountLines ( $sFilePath )

Parameters

$sFilePath Path and filename of the file to be read

Return Value

Success: | Returns number of lines in the file.
Failure: | Returns a 0
@Error: | 0 = No error.
 | 1 = File cannot be opened or found.

Remarks

It does not count a final @LF as a line.

Related

None.

Example

#include <file.au3>
$CountLines = _FileCountLines("error.log")
MsgBox(64, "Error log recordcount", "There are " & $CountLines & " in the error.log.")
Exit


Function _FileCreate

Function Reference

_FileCreate

Creates or zero's out the length of the file specified.

#include <File.au3>
_FileCreate ( $sFilePath )

Parameters

$sFilePath Path and filename of the file to be created.

Return Value

Success: | Returns a 1
Failure: | Returns a 0
@Error: | 0 = No error.
 | 1 = Error opening specified file
 | 2 = File could not be written to

Remarks

None.

Related

FileOpen

Example

#include <File.au3>
If Not _FileCreate("error.log") Then
MsgBox(4096,"Error", " Error Creating/Resetting log. error:" & @error)
EndIf


Function _FileListToArray

Function Reference

_FileListToArray

lists files and\or folders in a specified path (Similar to using Dir with the /B Switch)

#include <File.au3>
_FileListToArray ( $sPath [, $sFilter [, $iFlag]] )

Parameters

$sPath | Path to generate filelist for.
$sFilter | Optional the filter to use, default is *. Search the Autoit3 helpfile for the word "WildCards" For details.
$iFlag | Optional: specifies wheather to return files folders or both $iFlag=0(Default) Return both files and folders $iFlag=1 Return files only $iFlag=2 Return Folders only

Return Value

@Error: | 1 = Path not found or invalid
 | 2 = Invalid $sFilter
 | 3 = Invalid $iFlag
 | 4 = No File(s) Found

Remarks

The array returned is one-dimensional and is made up as follows:
$array[0] = Number of Files\Folders returned
$array[1] = 1st File\Folder
$array[2] = 2nd File\Folder
$array[3] = 3rd File\Folder
$array[n] = nth File\Folder

Related

None.

Example

#Include <File.au3>
#Include <Array.au3>
$FileList=_FileListToArray(@DesktopDir)
If @Error=1 Then
MsgBox (0,"","No Files\Folders Found.")
Exit
EndIf
_ArrayDisplay($FileList,"$FileList")


Function _FilePrint

Function Reference

_FilePrint

Prints a plain text file.

#include <File.au3>
_FilePrint ( $s_File [, $i_Show] )

Parameters

$s_File | The file to print.
$i_Show | The state of the window. (default = @SW_HIDE)

Return Value

Success: | Returns 1.
Failure: | Returns 0 and sets @error according to the global constants list.

Remarks

Uses the ShellExecute function of shell32.dll.

Related

None.

Example

#include <File.au3>

$file = FileOpenDialog("Print File", "", "Text Documents (*.txt)", 1)
If @error Then Exit

$print = _FilePrint($file)
If $print Then
MsgBox(0, "Print", "The file was printed.")
Else
MsgBox(0, "Print", "Error: " & @error & @CRLF & "The file was not printed.")
EndIf


Function _FileReadToArray

Function Reference

_FileReadToArray

Reads the specified file into an array.

#include <File.au3>
_FileReadToArray ( $sFilePath, $aArray )

Parameters

$sFilePath | Path and filename of the file to be read.
$aArray | The array to store the contents of the file.

Return Value

Success: | Returns a 1
Failure: | Returns a 0
@Error: | 0 = No error.
 | 1 = Error opening specified file

Remarks

$aArray[0] will contain the number of records read into the array.

Related

_FileWriteFromArray

Example

#include <file.au3>
Dim $aRecords
If Not _FileReadToArray("error.log",$aRecords) Then
MsgBox(4096,"Error", " Error reading log to Array error:" & @error)
Exit
EndIf
For $x = 1 to $aRecords[0]
Msgbox(0,'Record:' & $x, $aRecords[$x])
Next


Function _FileWriteFromArray

Function Reference

_FileWriteFromArray

Writes Array records to the specified file.

#include <File.au3>
_FileWriteFromArray ( $sFilePath, $a_Array [, $i_Base [, $i_UBound ]] )

Parameters

$sFilePath | Path and filename of the file to write to.
$a_Array | The array to be written to the file.
$i_Base | Optional: Start Array index to read, normally set to 0 or 1. Default=0
$i_Ubound | Optional: Set to the last record you want to write to the File. default=0 - whole array.

Return Value

Success: | Returns a 1
Failure: | Returns a 0
@Error: | 0 = No error.
 | 1 = Error opening specified file
 | 2 = Input is not an Array

Remarks

None.

Related

_FileReadToArray

Example

#include<Array.au3>
#include<File.au3>
Dim $a_Test
; Read file into array
_FileReadToArray("test.txt",$a_Test)
; reverse records
_ArrayReverse($a_Test,1)
; write reversed array to file
_FileWriteFromArray("test2.txt",$a_Test,1)


Function _FileWriteLog

Function Reference

_FileWriteLog

Writes current date,time and the specified text to a log file.

#include <File.au3>
_FileWriteLog ( $sLogPath, $sLogMsg )

Parameters

$sFilePath | Path and filename of the file to be written to
$sLogMsg | Message to be written to the log file

Return Value

Success: | Returns a 1
Failure: | Returns a 0
@Error: | 0 = No error.
 | 1 = Error opening specified file
 | 2 = File could not be written to

Remarks

None.

Related

FileOpen

Example

#include <file.au3>
;
_FileWriteLog(@ScriptDir & "\my.log","Text 1")
;
_FileWriteLog(@ScriptDir & "\my.log","Text 2")


Function _FileWriteToLine

Function Reference

_FileWriteToLine

Writes text to a specific line in a file.

#include <File.au3>
_FileWriteToLine ( $sFile, $iLine, $sText [, $fOverWrite] )

Parameters

$sFile | The file to write to
$iLine | The line number to write to
$sText | The text to write
$fOverWrite | if set to 1 will overwrite the old line if set to 0 will not overwrite

Return Value

Success: | 1
Failure: | 0
@Error: | 0 = No error
 | 1 = File has less lines than $iLine
 | 2 = File does not exist
 | 3 = Error when opening file
 | 4 = $iLine is invalid
 | 5 = $fOverWrite is invalid
 | 6 = $sText is invalid

Remarks

If _FileWriteToLine is called with $fOverWrite as 1 and $sText as "", it will delete the line.

Related

None.

Example

#include <File.au3>
;Example: Write to line 3 of c:\test.txt REPLACING line 3
_FileWriteToLine("c:\test.txt", 3, "my replacement for line 3", 1)
;Example: Write to line 3 of c:\test.txt NOT REPLACING line 3
_FileWriteToLine("c:\test.txt", 3, "my insertion", 0)


Function _PathFull

Function Reference

_PathFull

Creates a path based on the relative path you provide. The newly created absolute path is returned

#include <File.au3>
_PathFull ( $szRelPath )

Parameters

$szRelPath The relative path to be created

Return Value

Returns the newly created absolute path.

Remarks

None.

Related

_PathMake, _PathSplit, DirCreate, FileChangeDir

Example

#include <file.au3>
$TestPath = _PathFull(@ScriptDir & "..\..\test")
MsgBox(0,"demo _PathFull",@ScriptDir & @lf & $TestPath)


Function _PathMake

Function Reference

_PathMake

Creates a path from drive, directory, file name and file extension parts. Not all parts must be passed.
The path will still be built with what is passed. This doesn't check the validity of the path created, it could contain characters which are invalid on your filesystem.

#include <File.au3>
_PathMake ( $szDrive, $szDir, $szFName, $szExt )

Parameters

$szDrive | Drive (Can be UNC). If it's a drive letter, a : is automatically appended
$szDir | Directory. A trailing slash is added if not found (No preceeding slash is added)
$szFName | The name of the file
$szExt | The file extension. A period is supplied if not found in the extension

Return Value

Returns the string containing the full path

Remarks

None.

Related

_PathFull, _PathSplit, DirCreate, FileChangeDir

Example

#include <file.au3>
;


Function _PathSplit

Function Reference

_PathSplit

Splits a path into the drive, directory, file name and file extension parts. An empty string is set if a part is missing.

#include <File.au3>
_PathSplit ( $szPath, ByRef $szDrive, ByRef $szDir, ByRef $szFName, ByRef $szExt )

Parameters

$szPath | The path to be split (Can contain a UNC server or drive letter)
$szDrive | String to hold the drive
$szDir | String to hold the directory
$szFName | String to hold the file name
$szExt | String to hold the file extension

Return Value

Returns an array with 5 elements where 0 = original path, 1 = drive, 2 = directory, 3 = filename, 4 = extension

Remarks

This function does not take a command line string. It works on paths, not paths with arguments.

Related

_PathFull, _PathMake

Example

#include <file.au3>
#include <array.au3>
Dim $szDrive, $szDir, $szFName, $szExt
$TestPath = _PathSplit(@ScriptFullPath, $szDrive, $szDir, $szFName, $szExt)
_ArrayDisplay($TestPath,"Demo _PathSplit()")


Function _ReplaceStringInFile

Function Reference

_ReplaceStringInFile

Replaces a string with another string in the given text file (binary won't work!)

#include <File.au3>
_ReplaceStringInFile ( $szFileName, $szSearchString, $szReplaceString, $fCaseness = 0, $fOccurance = 1 )

Parameters

$szFileName | name of the file to open. ATTENTION !! Needs the FULL path, not just the name returned by eg. FileFindNextFile
$szSearchString | The string we want to replace in the file
$szReplaceString | The string we want as a replacement for $szSearchString
$fCaseness | 0 = Not Case sensitive (default), 1 = Case sensitive, case does matter
$fOccurance | 0 = Only first found is replaced, 1 = ALL occurrences are replaced (default)

Return Value

Success: | Returns the number of occurrences of $szSearchString we found
Failure: | Returns -1 and sets @error
 | @error=1 - Cannot open file
 | @error=2 - Cannot open temp file
 | @error=3 - Cannot write to temp file
 | @error=4 - Cannot delete original file
 | @error=5 - Cannot rename/move temp file
 | @error=6 - ReadOnly Attribute set.

Remarks

None.

Related

None.

Example

#include <File.au3>

$find = "BEFORE"
$replace = "AFTER"

$filename = "C:\_ReplaceStringInFile.test"

$msg = "Hello Test " & $find & " Hello Test" & @CRLF
$msg &= "Hello Test" & @CRLF
$msg &= @CRLF
$msg &= $find

FileWrite($filename, $msg )

msgbox(0,"BEFORE",$msg)

$retval = _ReplaceStringInFile($filename,$find,$replace)
if $retval = -1 then
msgbox(0, "ERROR", "The pattern could not be replaced in file: " & $filename & " Error: " & @error)
exit
else
msgbox(0, "INFO", "Found " & $retval & " occurances of the pattern: " & $find & " in the file: " & $filename)
endif

$msg = FileRead($filename, 1000)
msgbox(0,"AFTER",$msg)
FileDelete($filename)


Function _TempFile

Function Reference

_TempFile

Generate a name for a temporary file. The file is guaranteed not to exist yet.

#include <File.au3>
_TempFile ( [ $s_DirectoryName=@TempDIr [, $s_FilePrefix [, $s_FileExtension [, $i_RandomLength ]]]] )

Parameters

$s_DirectoryName | Optional: Name of directory for filename, defaults to the users %TEMP% directory
$s_FilePrefix | Optional: File prefixname, defaults to "~"
$s_FileExtension | Optional: File extenstion, defaults to ".tmp"
$i_RandomLength | Optional: Number of characters to use to generate a unique name, defaults to 7

Return Value

Filename of a temporary file which does not exist

Remarks

None.

Related

None.

Example

#include <File.au3>

Dim $s_TempFile, $s_FileName

; generate unique filename in @TempDir
$s_TempFile = _TempFile()

; generate unique filename in given directory and starting with tst_
$s_FileName = _TempFile("C:\", "tst_", ".txt", 7)

MsgBox(4096, "Info", "Names suitable for new temporary file : " & @LF & $s_TempFile & @LF & $s_FileName)

Exit


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: GuiCombo Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_GUICtrlComboAddDir | Add names to the list displayed by the combo box
_GUICtrlComboAddString | Add a string to the list box of a combo box
_GUICtrlComboAutoComplete | AutoComplete a combo box input
_GUICtrlComboDeleteString | Delete a string in the list box of a combo box
_GUICtrlComboFindString | Return the index of matching item
_GUICtrlComboGetCount | Retrieve the number of items in the list box of a combo box
_GUICtrlComboGetCurSel | Retrieve the index of the currently selected item, if any, in the list box of a combo box
_GUICtrlComboGetDroppedControlRect | Retrieve the screen coordinates of a combo box in its dropped-down state.
_GUICtrlComboGetDroppedState | Determine whether the list box of a combo box is dropped down
_GUICtrlComboGetDroppedWidth | Retrieve the minimum allowable width, of the list box of a combo box
_GUICtrlComboGetEditSel | Get the starting and ending character positions of the current selection in the edit control of a combo box.
_GUICtrlComboGetExtendedUI | Determine whether a combo box has the default user interface or the extended user interface
_GUICtrlComboGetHorizontalExtent | Retrieve from a combo box the width, in pixels
_GUICtrlComboGetItemHeight | Determine the height of list items or the selection field in a combo box
_GUICtrlComboGetLBText | Retrieve a string from the list of a combo box.
_GUICtrlComboGetLBTextLen | Retrieve the length, in characters, of a string in the list of a combo box
_GUICtrlComboGetList | Retrieves all items from the list portion of a ComboBox control.
_GUICtrlComboGetLocale | Retrieve the current locale of the combo box
_GUICtrlComboGetMinVisible | Get the minimum number of visible items in the drop-down list of a combo box
_GUICtrlComboGetTopIndex | Retrieve the zero-based index of the first visible item in the list box portion of a combo box
_GUICtrlComboInitStorage | Allocates memory for storing list box portion of the combo box items
_GUICtrlComboInsertString | Insert a string into the list box of a combo box
_GUICtrlComboLimitText | Limit the length of the text the user may type into the edit control of a combo box
_GUICtrlComboResetContent | Remove all items from the list box and edit control of a combo box
_GUICtrlComboSelectString | Search the list of a combo box for an item that begins with the characters in a specified string
_GUICtrlComboSetCurSel | Select a string in the list of a combo box
_GUICtrlComboSetDroppedWidth | Set the maximum allowable width
_GUICtrlComboSetEditSel | Select characters in the edit control of a combo box
_GUICtrlComboSetExtendedUI | Select either the default user interface or the extended user interface
_GUICtrlComboSetHorizontalExtent | Set the width, in pixels
_GUICtrlComboSetItemHeight | Set the height of list items or the selection field in a combo box
_GUICtrlComboSetMinVisible | Set the minimum number of visible items in the drop-down list of a combo box
_GUICtrlComboSetTopIndex | Ensure that a particular item is visible
_GUICtrlComboShowDropDown | Show or hide the list box of a combo box


Function _GUICtrlComboAddDir

Function Reference

_GUICtrlComboAddDir

Add names to the list displayed by the combo box

#Include <GuiCombo.au3>
_GUICtrlComboAddDir ( $h_combobox, $s_Attributes [, $s_file] )

Parameters

$h_combobox | control id/control hWnd
$s_Attributes | comma-delimited string
$s_file | Optional for "Drives" only: what Files/Folders to get eg *.*

Return Value

Success: | Returns zero-based index of the last name added to the list.
Failure: | Returns $CB_ERR.
 | Returns $CB_ERRSPACE if there is insufficient space to store the new strings.

Remarks

Requirement: $s_file for all but drives attribute

$s_Attributes is an comma-delimited string
valid values are any of the following:
A,D,H,RO,RW,S,E,Drives,NB

A = ARCHIVE | Includes archived files.
D = DIRECTORY | Includes subdirectories. Subdirectory names are enclosed in square brackets ([ ]).
H = HIDDEN | Includes hidden files.
RO = READONLY | Includes read-only files.
RW = READWRITE | Includes read-write files with no additional attributes. This is the default setting.
S = SYSTEM | Includes system files.
E = EXCLUSIVE | Includes only files with the specified attributes. By default, read-write files are listed even if READWRITE is not specified.
DRIVES | All mapped drives are added to the list. Drives are listed in the form [-x-], where x is the drive letter.
NB = No Brackets |
Drives are listed in the form x:, where x is the drive letter (used with Drives attribute) |

Related

_GUICtrlComboInitStorage

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>
#Include <GuiStatusBar.au3>

Opt('MustDeclareVars', 1)

Dim $a_check[10], $msg, $ret, $s_attr, $allocated, $Status, $GUI
Dim $input, $group, $a_attr, $Combo, $button, $btn_exit

$GUI = GUICreate("ComboBox Add Dir", 400, 280)

GUICtrlCreateLabel("Enter files to find", 25, 15)
$input = GUICtrlCreateInput("", 125, 10, 180, 25)
$group = GUICtrlCreateGroup("Atrributes", 10, 40, -1, 200)
$a_attr = StringSplit("A,D,H,RO,RW,S,E,Drives,NB", ",")
$a_check[0] = 9
$a_check[1] = GUICtrlCreateCheckbox("Archive", 15, 55, 170, 20)
$a_check[2] = GUICtrlCreateCheckbox("Directory", 15, 75, 170, 20)
$a_check[3] = GUICtrlCreateCheckbox("Hidden", 15, 95, 170, 20)
$a_check[4] = GUICtrlCreateCheckbox("Read-Only", 15, 115, 170, 20)
$a_check[5] = GUICtrlCreateCheckbox("Read-Write", 15, 135, 95, 20)
$a_check[6] = GUICtrlCreateCheckbox("System", 15, 155, 170, 20)
$a_check[7] = GUICtrlCreateCheckbox("Exclusive", 15, 175, 170, 20)
$a_check[8] = GUICtrlCreateCheckbox("Drives", 15, 195, 170, 20)
$a_check[9] = GUICtrlCreateCheckbox("No Brackets (Drives Only)", 15, 215, 170, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

$Combo = GUICtrlCreateCombo("", 240, 40, 120, 120, $CBS_SIMPLE)
$allocated = _GUICtrlComboInitStorage ($Combo, 26, 50)

$button = GUICtrlCreateButton("Get Names", 240, 160, 120, 40)
$btn_exit = GUICtrlCreateButton("Exit", 240, 205, 120, 40)

$Status = _GUICtrlStatusBarCreate ($GUI, -1, "")
_GUICtrlStatusBarSetSimple ($Status)
_GUICtrlStatusBarSetText ($Status, "Pre-Allocated Memory For: " & $allocated & _
" Items Added To ComboBox: " & _GUICtrlComboGetCount ($Combo), 255)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $btn_exit
ExitLoop
Case $msg = $button
$s_attr = ""
For $i = 1 To $a_check[0]
If (BitAND(GUICtrlRead($a_check[$i]), $GUI_CHECKED)) Then
If (StringLen($s_attr) > 0) Then
$s_attr &= "," & $a_attr[$i]
Else
$s_attr = $a_attr[$i]
EndIf
EndIf
Next
_GUICtrlComboResetContent ($Combo)
$ret = _GUICtrlComboAddDir ($Combo, $s_attr, GUICtrlRead($input))
If ($ret < 0) Then
If ($ret == $CB_ERRATTRIBUTE) Then
MsgBox(16, "Error", "Invalid Attribute sent to _GUICtrlComboAddDir")
ElseIf ($ret == $CB_ERRSPACE) Then
MsgBox(16, "Error", "insufficient space to store the new strings from calling _GUICtrlComboAddDir")
ElseIf ($ret == $CB_ERRREQUIRED) Then
MsgBox(16, "Error", "Argument required for file search in call to _GUICtrlComboAddDir")
ElseIf ($ret == $CB_ERR) Then
MsgBox(16, "Error", "Unknown error from _GUICtrlComboAddDir" & @CRLF & "Possibly no files/folders found")
EndIf
EndIf
_GUICtrlStatusBarSetText ($Status, "Pre-Allocated Memory For: " & $allocated & _
" Items Added To ComboBox: " & _GUICtrlComboGetCount ($Combo), 255)
EndSelect
WEnd
Exit


Function _GUICtrlComboAddString

Function Reference

_GUICtrlComboAddString

Add a string to the list box of a combo box

#Include <GuiCombo.au3>
_GUICtrlComboAddString ( $h_combobox, $s_text )

Parameters

$h_combobox | control id/control hWnd
$s_text | string to add

Return Value

Success: | Return zero-based index of the last name added to the list
Failure: | Returns $CB_ERR.
 | Returns $CB_ERRSPACE if there is insufficient space to store the new strings.

Remarks

If the combo box does not have the $CBS_SORT style,
the string is added to the end of the list.
Otherwise, the string is inserted into the list, and the list is sorted.

Related

_GUICtrlComboDeleteString, _GUICtrlComboInsertString, _GUICtrlComboResetContent

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Label,$Input,$Btn_Add,$Combo,$Btn_Exit,$msg

GuiCreate("ComboBox Add String", 392, 254)

$Label = GuiCtrlCreateLabel("Enter String to Add", 20, 20, 120, 20)
$Input = GuiCtrlCreateInput("", 160, 20, 180, 20)
$Btn_Add = GuiCtrlCreateButton("Add String", 210, 50, 90, 30)
$Combo = GuiCtrlCreateCombo("A", 70, 100, 270, 120)
GUICtrlSetData($Combo,"B|C|D|E|F")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)

GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_Add
If(StringLen(GUICtrlRead($Input)) > 0) Then
_GUICtrlComboAddString($Combo,GUICtrlRead($Input))
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlComboAutoComplete

Function Reference

_GUICtrlComboAutoComplete

AutoComplete a combo box input

#Include <GuiCombo.au3>
_GUICtrlComboAutoComplete ( $h_combobox, ByRef $s_text )

Parameters

$h_combobox | control id/control hWnd
$s_text | String for comparing against the combo's input box

Return Value

None

Remarks

None.

Related

None.

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt ('MustDeclareVars', 1)

Dim $Combo, $Btn_Exit, $msg, $old_string = ""

GUICreate("ComboBox AutoComplete", 392, 254)

$Combo = GUICtrlCreateCombo("", 70, 100, 270, 120)
GUICtrlSetData($Combo, "AutoIt|v3|is|freeware|BASIC-like|scripting|language|Autobot|Animal")
$Btn_Exit = GUICtrlCreateButton("Exit", 150, 180, 90, 30)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case Else
_GUICtrlComboAutoComplete ($Combo, $old_string)
EndSelect
WEnd
Exit


Function _GUICtrlComboDeleteString

Function Reference

_GUICtrlComboDeleteString

Delete a string in the list box of a combo box

#Include <GuiCombo.au3>
_GUICtrlComboDeleteString ( $h_combobox, $i_index )

Parameters

h_combobox | control id/control hWnd
$i_index | Specifies the zero-based index of the string

Return Value

Success: | Returns value is a count of the strings remaining in the list.
Failure: | Returns $CB_ERR if the $i_index parameter specifies an index greater than the number of items in the list.

Remarks

None.

Related

_GUICtrlComboAddString, _GUICtrlComboInsertString, _GUICtrlComboResetContent

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Combo, $Btn_Delete, $Btn_Exit, $msg

GuiCreate("ComboBox Delete String", 392, 254)

$Combo = GuiCtrlCreateCombo("A", 70, 10, 270, 110,$CBS_SIMPLE)
$Btn_Delete = GuiCtrlCreateButton("Delete String", 135, 120, 90, 30)
GUICtrlSetData($Combo,"B|C|D|E|F")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)

GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_Delete
If(_GUICtrlComboGetCurSel($Combo) <> $CB_ERR) Then
_GUICtrlComboDeleteString($Combo,_GUICtrlComboGetCurSel($Combo))
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlComboFindString

Function Reference

_GUICtrlComboFindString

Return the index of matching item

#Include <GuiCombo.au3>
_GUICtrlComboFindString ( $h_combobox, $s_search [, $i_exact=0] )

Parameters

$h_combobox | control id/control hWnd
$s_search | string to search for
$i_exact | Optional: exact match or not

Return Value

Success: | Returns is the zero-based index of the matching item.
Failure: | Returns $CB_ERR if the search is unsuccessful.

Remarks

$i_exact = 0 Search the list box of a combo box for an item beginning with
the characters in a specified string
$i_exact <> 0 Find the first list box string in a combo box that matches
the string specified in the $s_search parameter

Related

_GUICtrlComboSelectString

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Label,$Input,$Btn_Search,$Btn_ExactSearch,$Combo,$Btn_Exit,$Status,$msg,$ret

GuiCreate("ComboBox Find String", 392, 254)

$Label = GuiCtrlCreateLabel("Enter Search String", 20, 20, 120, 20)
$Input = GuiCtrlCreateInput("", 160, 20, 180, 20)
$Btn_Search = GuiCtrlCreateButton("Search", 160, 50, 90, 30)
$Btn_ExactSearch = GuiCtrlCreateButton("Exact Search", 255, 50, 90, 30)
$Combo = GuiCtrlCreateCombo("", 70, 100, 270, 120)
GUICtrlSetData($Combo,"AutoIt|v3|is|freeware|BASIC-like|scripting|language")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_Search
If(StringLen(GUICtrlRead($Input)) > 0) Then
$ret = _GUICtrlComboFindString($Combo,GUICtrlRead($Input))
If($ret <> $CB_ERR) Then
GUICtrlSetData($Status,'Found "' & GUICtrlRead($Input) & '" at index: ' & $ret)
Else
GUICtrlSetData($Status,'"' & GUICtrlRead($Input) & '" Not Found')
EndIf
EndIf
Case $msg = $Btn_ExactSearch
If(StringLen(GUICtrlRead($Input)) > 0) Then
$ret = _GUICtrlComboFindString($Combo,GUICtrlRead($Input),1)
If($ret <> $CB_ERR) Then
GUICtrlSetData($Status,'Found "' & GUICtrlRead($Input) & '" at index: ' & $ret)
Else
GUICtrlSetData($Status,'"' & GUICtrlRead($Input) & '" Not Found')
EndIf
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlComboGetCount

Function Reference

_GUICtrlComboGetCount

Retrieve the number of items in the list box of a combo box

#Include <GuiCombo.au3>
_GUICtrlComboGetCount ( $h_combobox )

Parameters

$h_combobox control id/control hWnd

Return Value

The return value is the number of items in the list box.

Remarks

The index is zero-based, so the returned count is one greater
than the index value of the last item.

Related

_GUICtrlComboAddString, _GUICtrlComboInsertString, _GUICtrlComboSelectString

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Combo,$ret,$Btn_Exit,$Status,$msg

GuiCreate("ComboBox Get Count", 392, 254)

$Combo = GuiCtrlCreateCombo("", 70, 10, 270, 100,$CBS_SIMPLE)
$ret = _GUICtrlComboAddDir($Combo,"drives")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))
GUICtrlSetData($Status,"Items in ComboBox: " & _GUICtrlComboGetCount($Combo))
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
EndSelect
WEnd
Exit


Function _GUICtrlComboGetCurSel

Function Reference

_GUICtrlComboGetCurSel

Retrieve the index of the currently selected item, if any, in the list box of a combo box

#Include <GuiCombo.au3>
_GUICtrlComboGetCurSel ( $h_combobox )

Parameters

$h_combobox control id/control hWnd

Return Value

The return value is the zero-based index of the currently selected item.

Remarks

None.

Related

_GUICtrlComboSetCurSel, _GUICtrlComboInsertString, _GUICtrlComboSetTopIndex

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Combo,$ret,$Btn_Exit,$Status,$msg,$ret

GuiCreate("ComboBox Get Current Selection", 392, 254)

$Combo = GuiCtrlCreateCombo("", 70, 10, 270, 100,$CBS_SIMPLE)
$ret = _GUICtrlComboAddDir($Combo,"drives")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Combo
$ret = _GUICtrlComboGetCurSel($Combo)
If($ret <> $CB_ERR) Then GUICtrlSetData($Status,"Items Selected (Index): " & $ret)
EndSelect
WEnd
Exit


Function _GUICtrlComboGetDroppedControlRect

Function Reference

_GUICtrlComboGetDroppedControlRect

Retrieve the screen coordinates of a combo box in its dropped-down state.

#Include <GuiCombo.au3>
_GUICtrlComboGetDroppedControlRect ( $h_combobox )

Parameters

$h_combobox control id/control hWnd

Return Value

Success: | Returns array containing the RECT, first element ($array[0]) contains the number of elements.
Failure: | Returns $CB_ERR if an error occurs.

Remarks

$array[1] - left
$array[2] - top
$array[3] - right
$array[4] - bottom

Related

_GUICtrlComboGetDroppedState, _GUICtrlComboGetDroppedWidth

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

opt('MustDeclareVars', 1)

Dim $Combo, $Btn_Exit, $msg, $label_rect, $s_rect, $Btn_GETRECT

GUICreate("ComboBox Get Dropped Control RECT", 392, 254)

$Combo = GUICtrlCreateCombo("", 70, 10, 270, 120)
GUICtrlSetData($Combo, "AutoIt|v3|is|freeware|BASIC-like|scripting|language|designed|for|automating|the Windows GUI.")

$Btn_GETRECT = GUICtrlCreateButton("Get Dropped Control Rect", 150, 130, 90, 40, $BS_MULTILINE)
$Btn_Exit = GUICtrlCreateButton("Exit", 150, 180, 90, 30)

$s_rect = "Left:" & @LF & "Top:" & @LF & "Right:" & @LF & "Bottom:"
$label_rect = GUICtrlCreateLabel($s_rect, 145, 50, 100, 55, $SS_SUNKEN)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_GETRECT
Local $rect_array = _GUICtrlComboGetDroppedControlRect($Combo)
If (IsArray($rect_array)) Then
$s_rect = "Left:" & $rect_array[1] & @LF & "Top:" & $rect_array[2] & @LF & "Right:" & $rect_array[3] & @LF & "Bottom:" & $rect_array[4]
GUICtrlSetData($label_rect, $s_rect)
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlComboGetDroppedState

Function Reference

_GUICtrlComboGetDroppedState

Determine whether the list box of a combo box is dropped down

#Include <GuiCombo.au3>
_GUICtrlComboGetDroppedState ( $h_combobox )

Parameters

$h_combobox control id/control hWnd

Return Value

Success: | Returns TRUE if the list box is visible.
Failure: | Returns FALSE otherwise.

Remarks

None.

Related

_GUICtrlComboGetDroppedWidth, _GUICtrlComboSetDroppedWidth, _GUICtrlComboShowDropDown

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Combo,$Btn_Exit,$Status,$msg,$state,$current

GuiCreate("ComboBox Dropped State", 392, 254)

$Combo = GuiCtrlCreateCombo("", 70, 10, 270, 120)
GUICtrlSetData($Combo,"AutoIt|v3|is|freeware|BASIC-like|scripting|language")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))
GUICtrlSetData($Status,"Dropped State: False")
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case Else
$state = _GUICtrlComboGetDroppedState($Combo)
If($state And $state <> $current) Then
$current = $state
GUICtrlSetData($Status,"Dropped State: True")
ElseIf($state <> $current) Then
$current = $state
GUICtrlSetData($Status,"Dropped State: False")
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlComboGetDroppedWidth

Function Reference

_GUICtrlComboGetDroppedWidth

Retrieve the minimum allowable width, of the list box of a combo box

#Include <GuiCombo.au3>
_GUICtrlComboGetDroppedWidth ( $h_combobox )

Parameters

$h_combobox control id/control hWnd

Return Value

None.

Remarks

Requirement: $CBS_DROPDOWN or $CBS_DROPDOWNLIST style

Related

_GUICtrlComboGetDroppedState, _GUICtrlComboSetDroppedWidth

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Combo,$Btn_Exit,$Status,$msg

GuiCreate("ComboBox Dropped Width", 392, 254)

$Combo = GuiCtrlCreateCombo("", 70, 10, 270, 120)
GUICtrlSetData($Combo,"AutoIt|v3|is|freeware|BASIC-like|scripting|language")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))
GUICtrlSetData($Status,"Drop Width: " & _GUICtrlComboGetDroppedWidth($Combo))
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
EndSelect
WEnd
Exit


Function _GUICtrlComboGetEditSel

Function Reference

_GUICtrlComboGetEditSel

Get the starting and ending character positions of the current selection in the edit control of a combo box.

#Include <GuiCombo.au3>
_GUICtrlComboGetEditSel ( $h_combobox )

Parameters

$h_combobox control id/control hWnd

Return Value

Array containing the starting and ending selected positions, first element ($array[0]) contains the number of elements
If an error occurs, the return value is $CB_ERR.

Remarks

$array[1] - starting position
$array[2] - ending position

Related

_GUICtrlComboSetEditSel

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

opt('MustDeclareVars', 1)

Dim $Combo, $Btn_Exit, $msg, $Status

GUICreate("ComboBox Get Edit Sel", 392, 254)

$Combo = GUICtrlCreateCombo("", 70, 10, 270, 100, $CBS_SIMPLE)
GUICtrlSetData($Combo, "AutoIt|v3|is|freeware|BASIC-like|scripting|language", "freeware")
$Btn_Exit = GUICtrlCreateButton("Exit", 150, 200, 90, 30)

$Status = GUICtrlCreateLabel("", 0, 234, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
Local $a_sel = _GUICtrlComboGetEditSel($Combo)
If (IsArray($a_sel)) Then
GUICtrlSetData($Status, "Chars Position Selected From: " & $a_sel[1] & " To: " & $a_sel[2])
EndIf

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
EndSelect
WEnd
Exit


Function _GUICtrlComboGetExtendedUI

Function Reference

_GUICtrlComboGetExtendedUI

Determine whether a combo box has the default user interface or the extended user interface

#Include <GuiCombo.au3>
_GUICtrlComboGetExtendedUI ( $h_combobox )

Parameters

$h_combobox control id/control hWnd

Return Value

Success: | Returns TRUE if the combo box has the extended user interface.
Failure: | Returns FALSE otherwise.

Remarks

By default, the F4 key opens or closes the list and the
DOWN ARROW changes the current selection.

In a combo box with the extended user interface, the F4
key is disabled and pressing the DOWN ARROW key opens the
drop-down list.

Related

_GUICtrlComboSetExtendedUI

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Combo,$Btn_Exit,$Status,$msg,$Btn_Standard,$Btn_Extended,$state,$current

GuiCreate("ComboBox Get Extended UI", 392, 254)

$Combo = GuiCtrlCreateCombo("", 70, 10, 270, 120)
GUICtrlSetData($Combo,"AutoIt|v3|is|freeware|BASIC-like|scripting|language")
$Btn_Standard = GuiCtrlCreateButton("Standard", 75, 90, 90, 30)
$Btn_Extended = GuiCtrlCreateButton("Extended", 200, 90, 90, 30)
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))
$current = Not $state
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_Standard
_GUICtrlComboSetExtendedUI($Combo, 0)
Case $msg = $Btn_Extended
_GUICtrlComboSetExtendedUI($Combo, 1)
Case Else
$state = _GUICtrlComboGetExtendedUI($Combo)
If($state And $state <> $current) Then
$current = $state
GUICtrlSetData($Status,"Extend UI: True")
ElseIf($state <> $current) Then
$current = $state
GUICtrlSetData($Status,"Extend UI: False")
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlComboGetHorizontalExtent

Function Reference

_GUICtrlComboGetHorizontalExtent

Retrieve from a combo box the width, in pixels

#Include <GuiCombo.au3>
_GUICtrlComboGetHorizontalExtent ( $h_combobox )

Parameters

$h_combobox control id/control hWnd

Return Value

The return value is the scrollable width, in pixels.

Remarks

Retrieve from a combo box the width, in pixels, by which the
list box can be scrolled horizontally (the scrollable width).
This is applicable only if the list box has a horizontal scroll bar.

Related

_GuICtrlComboSetHorizontalExtent

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Combo,$Btn_Exit,$Status,$msg

GuiCreate("ComboBox Get Horizontal Extent", 392, 254)

$Combo = GuiCtrlCreateCombo("", 70, 10, 100, 150,BitOR($CBS_SIMPLE,$CBS_DISABLENOSCROLL,$WS_HSCROLL))
GUICtrlSetData($Combo,"AutoIt v3 is freeware BASIC-like scripting language designed for automating the Windows GUI.|" & _
"It uses a combination of simulated keystrokes mouse movement and window/control manipulation|" & _
"in order to automate tasks in a way not possible or reliable with other languages|" & _
"(e.g. VBScript and SendKeys).")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))
_GuICtrlComboSetHorizontalExtent($Combo, 500)
GUICtrlSetData($Status,"Horizontal Extent: " & _GUICtrlComboGetHorizontalExtent($Combo))
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
EndSelect
WEnd
Exit


Function _GUICtrlComboGetItemHeight

Function Reference

_GUICtrlComboGetItemHeight

Determine the height of list items or the selection field in a combo box

#Include <GuiCombo.au3>
_GUICtrlComboGetItemHeight ( $h_combobox [, $i_index=-1] )

Parameters

$h_combobox | control id/control hWnd
$i_index | Optional: Specifies the zero-based index of the string

Return Value

The return value is the height, in pixels, of the list items in a combo box.
If the combo box has the CBS_OWNERDRAWVARIABLE style, it is the height of the
item specified by the $i_index parameter. If $i_index is –1, the return value
is the height of the edit control (or static-text) portion of the combo box.
If an error occurs, the return value is $CB_ERR

Remarks

None.

Related

_GUICtrlComboSetItemHeight

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Combo,$Btn_Exit,$msg,$Status

GuiCreate("ComboBox Get Item Height", 392, 254)

$Combo = GuiCtrlCreateCombo("A", 70, 10, 270, 100,$CBS_SIMPLE)
GUICtrlSetData($Combo,"B|C|D|E|F")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))
GUICtrlSetData($Status,"Item 1 Height " & _GUICtrlComboGetItemHeight($Combo, 1))

GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
EndSelect
WEnd
Exit


Function _GUICtrlComboGetLBText

Function Reference

_GUICtrlComboGetLBText

Retrieve a string from the list of a combo box.

#Include <GuiCombo.au3>
_GUICtrlComboGetLBText ( $h_combobox, $i_index, ByRef $s_text )

Parameters

$h_combobox | control id/control hWnd
$i_index | Specifies the zero-based index of the string to retrieve.
$s_text | Buffer that receives the string

Return Value

Success: | Returns is the length of the string in TCHARs, excluding the terminating null character.
Failure: | Returns $CB_ERR if $i_index does not specify a valid index.

Remarks

None.

Related

_GUICtrlComboGetLBTextLen

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

opt('MustDeclareVars', 1)

Dim $Combo, $Btn_Exit, $Status, $msg, $Btn_Get, $Input_item

GUICreate("ComboBox Get LB Text", 392, 254)

$Combo = GUICtrlCreateCombo("", 70, 10, 270, 120)
GUICtrlSetData($Combo, "AutoIt|v3|is|freeware|BASIC-like|scripting|language|designed|for|automating|the Windows GUI.")

GUICtrlCreateLabel("Enter index number of item:", 65, 112, 130, 20, $SS_RIGHT)
$Input_item = GUICtrlCreateInput("0", 200, 110, 50, 20, $ES_NUMBER)
GUICtrlSetLimit($Input_item, 2)

$Btn_Get = GUICtrlCreateButton("Get Text", 150, 140, 90, 30)
$Btn_Exit = GUICtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("", 0, 234, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
GUICtrlSetData($Status, "Items: " & _GUICtrlComboGetCount ($Combo))

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_Get
Local $s_text
Local $i_count = _GUICtrlComboGetLBText ($Combo, Int(GUICtrlRead($Input_item)), $s_text)
If ($i_count == $CB_ERR) Then
GUICtrlSetData($Status, "Invalid Index: " & GUICtrlRead($Input_item))
Else
GUICtrlSetData($Status, "Len: " & $i_count & ", Index: " & GUICtrlRead($Input_item) & " = " & $s_text)
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlComboGetLBTextLen

Function Reference

_GUICtrlComboGetLBTextLen

Retrieve the length, in characters, of a string in the list of a combo box

#Include <GuiCombo.au3>
_GUICtrlComboGetLBTextLen ( $h_combobox, $i_index )

Parameters

$h_combobox | control id/control hWnd
$i_index | Specifies the zero-based index of the string

Return Value

Success: | Returns is the length of the string, in TCHARs, excluding the terminating null character.
 | If an ANSI string this is the number of bytes, and if it is a Unicode string this is the number of characters.
Failure: | Returns $CB_ERR if the $i_index parameter does not specify a valid index.

Remarks

Under certain conditions, the return value is larger than the
actual length of the text. This occurs with certain mixtures of
ANSI and Unicode, and is due to the operating system allowing for
the possible existence of double-byte character set (DBCS) characters
within the text. The return value, however, will always be at least
as large as the actual length of the text; so you can always use it
to guide buffer allocation.

This behavior can occur when an application uses both ANSI functions
and common dialogs, which use Unicode.

To obtain the exact length of the text, use the WM_GETTEXT, LB_GETTEXT,
or CB_GETLBTEXT messages, or the GetWindowText function

Related

_GUICtrlComboSetEditSel

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Combo,$Btn_Exit,$Status,$msg

GuiCreate("ComboBox Get LB Text Len", 392, 254)

$Combo = GuiCtrlCreateCombo("", 70, 10, 270, 100,$CBS_SIMPLE)
GUICtrlSetData($Combo,"AutoIt|v3|is|freeware|BASIC-like|scripting|language")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Combo
If(_GUICtrlComboGetCurSel($Combo) <> $CB_ERR) Then
GUICtrlSetData($Status,"Length of Item[" & _GUICtrlComboGetCurSel($Combo) & "] = " & _GUICtrlComboGetLBTextLen($Combo, _GUICtrlComboGetCurSel($Combo)))
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlComboGetList

Function Reference

_GUICtrlComboGetList

Retrieves all items from the list portion of a ComboBox control.

#include <GUICombo.au3>
_GUICtrlComboGetList ( $idCombo [, $sDelimiter = "|" ] )

Parameters

$idCombo | Control ID of the combo.
$sDelimiter | Delimeter used to seperate each item (Defaults to |).

Return Value

Delimited string of all ComboBox items.

Remarks

None.

Related

_GUICtrlComboGetLBText

Example

#include <GUIConstants.au3>
#include <GUICombo.au3>

GUICreate("My GUI combo")

Global $g_idCombo = GUICtrlCreateCombo ("", 10, 10, 100, 120)
GUICtrlSetData($g_idCombo, "item1|item1")

GUISetState ()

While 1
If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
Wend

MsgBox(4096, "", _GUICtrlComboGetList($g_idCombo))


Function _GUICtrlComboGetLocale

Function Reference

_GUICtrlComboGetLocale

Retrieve the current locale of the combo box

#Include <GuiCombo.au3>
_GUICtrlComboGetLocale ( $h_combobox )

Parameters

$h_combobox control id/control hWnd

Return Value

Returns the current Local of the combobox
same as @OSLang unless changed

Remarks

"0409" for U.S. English
see @OSLang for string values

Related

None.

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Combo,$Btn_Exit,$Status,$msg

GuiCreate("ComboBox Get Locale", 392, 254)

$Combo = GuiCtrlCreateCombo("", 70, 10, 270, 100,$CBS_SIMPLE)
GUICtrlSetData($Combo,"AutoIt|v3|is|freeware|BASIC-like|scripting|language")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))
GUICtrlSetData($Status,"Locale: " & _GUICtrlComboGetLocale($Combo))
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
EndSelect
WEnd
Exit


Function _GUICtrlComboGetMinVisible

Function Reference

_GUICtrlComboGetMinVisible

Get the minimum number of visible items in the drop-down list of a combo box

#Include <GuiCombo.au3>
_GUICtrlComboGetMinVisible ( $h_combobox )

Parameters

$h_combobox control id/control hWnd

Return Value

The return value is the minimum number of visible items

Remarks

When the number of items in the drop-down list is greater
than the minimum, the combo box uses a scrollbar.

This message is ignored if the combo box control has style
$CBS_NOINTEGRALHEIGHT.

To use $CB_GETMINVISIBLE, the application must specify comctl32.dll
version 6 in the manifest. For more information, see
Using Windows XP Visual Styles

Related

_GUICtrlComboSetMinVisible

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Combo,$Btn_Exit,$Status,$msg

GuiCreate("ComboBox Get Min Visible", 392, 254)

$Combo = GuiCtrlCreateCombo("", 70, 10, 270, 100,$CBS_SIMPLE)
GUICtrlSetData($Combo,"AutoIt|v3|is|freeware|BASIC-like|scripting|language")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))
GUICtrlSetData($Status,"Min Visible: " & _GUICtrlComboGetMinVisible($Combo))
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
EndSelect
WEnd
Exit


Function _GUICtrlComboGetTopIndex

Function Reference

_GUICtrlComboGetTopIndex

Retrieve the zero-based index of the first visible item in the list box portion of a combo box

#Include <GuiCombo.au3>
_GUICtrlComboGetTopIndex ( $h_combobox )

Parameters

$h_combobox control id/control hWnd

Return Value

Success: | Returns is the index of the first visible item in the list box of the combo box.
Failure: | Returns $CB_ERR if the message fails.

Remarks

Initially, the item with index 0 is at the top of the list box,
but if the list box contents have been scrolled, another item may be at the top

Related

_GUICtrlComboSetTopIndex

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Combo,$Btn_Exit,$Status,$msg,$Btn_Get

GuiCreate("ComboBox Get Top Index", 392, 254)

$Combo = GuiCtrlCreateCombo("", 70, 10, 270, 100,BitOR($CBS_SIMPLE,$CBS_DISABLENOSCROLL,$WS_VSCROLL))
GUICtrlSetData($Combo,"AutoIt|v3|is|freeware|BASIC-like|scripting|language|designed|for|automating")
$Btn_Get = GuiCtrlCreateButton("Get Top Index", 150, 140, 90, 30)
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))
GUICtrlSetData($Status,"Top Index: " & _GUICtrlComboGetTopIndex($Combo))
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_Get
GUICtrlSetData($Status,"Top Index: " & _GUICtrlComboGetTopIndex($Combo))
EndSelect
WEnd
Exit


Function _GUICtrlComboInitStorage

Function Reference

_GUICtrlComboInitStorage

Allocates memory for storing list box portion of the combo box items

#Include <GuiCombo.au3>
_GUICtrlComboInitStorage ( $h_combobox, $i_num, $i_bytes )

Parameters

$h_combobox | control id/control hWnd
$i_num | Specifies the number of items to add
$i_bytes | Specifies the amount of memory to allocate for item strings, in bytes

Return Value

Success: | Returns is the total number
Failure: | Returns $CB_ERRSPACE if the message fails.

Remarks

Windows NT 4.0: This message does not allocate the specified amount of memory
however, it always returns the value specified in the $i_num parameter.

Windows 2000/XP: The message allocates memory and returns the success and error values described above

The $CB_INITSTORAGE message helps speed up the initialization of combo boxes
that have a large number of items (over 100).

It reserves the specified amount of memory so that subsequent $CB_ADDSTRING,
$CB_INSERTSTRING, and $CB_DIR messages take the shortest possible time.

You can use estimates for the $i_num and $i_bytes parameters.

If you overestimate, the extra memory is allocated, if you underestimate,
the normal allocation is used for items that exceed the requested amount

Related

_GUICtrlComboAddDir

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Combo,$ret,$Btn_Exit,$Status,$msg,$allocated

GuiCreate("ComboBox Init Storage", 392, 254)

$Combo = GuiCtrlCreateCombo("", 70, 10, 270, 100,$CBS_SIMPLE)
$allocated = _GUICtrlComboInitStorage($Combo, 26, 50)
$ret = _GUICtrlComboAddDir($Combo,"drives")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))
GUICtrlSetData($Status,"Pre-Allocated Memory For: " & $allocated & " Items, Drives Added To ComboBox: " & _GUICtrlComboGetCount($Combo))
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
EndSelect
WEnd
Exit


Function _GUICtrlComboInsertString

Function Reference

_GUICtrlComboInsertString

Insert a string into the list box of a combo box

#Include <GuiCombo.au3>
_GUICtrlComboInsertString ( $h_combobox, $i_index , $s_text )

Parameters

$h_combobox | control id/control hWnd
$i_index | Specifies the zero-based index of the position at which to insert the string
$s_text | String to insert

Return Value

Success: | Return the index of the position at which the string was inserted.
Failure: | Returns $CB_ERR if an error occurs.
 | Returns $CB_ERRSPACE if there is insufficient space to store the new strings.

Remarks

If the $i_index parameter is –1, the string is added to the end of the list.

If the combo box has $WS_HSCROLL style and you insert a string wider than the
combo box, you should send a LB_SETHORIZONTALEXTENT message to ensure the
horizontal scrollbar appears

Related

_GUICtrlComboAddString, _GUICtrlComboDeleteString, _GUICtrlComboResetContent

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Label,$Input,$Btn_Insert,$Combo,$Btn_Exit,$msg,$Status,$i_index

GuiCreate("ComboBox Insert String", 392, 254)

$Label = GuiCtrlCreateLabel("Enter String to Insert", 20, 20, 120, 20)
$Input = GuiCtrlCreateInput("", 160, 20, 180, 20)
$Btn_Insert = GuiCtrlCreateButton("Add String", 210, 50, 90, 30)
$Combo = GuiCtrlCreateCombo("A", 70, 100, 270, 100,$CBS_SIMPLE)
GUICtrlSetData($Combo,"B|C|D|E|F")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 200, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))

GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_Insert
If(StringLen(GUICtrlRead($Input)) > 0) Then
$i_index =_GUICtrlComboInsertString($Combo,_GUICtrlComboGetCurSel($Combo),GUICtrlRead($Input))
GUICtrlSetData($Status,"String Inserted At Index: " & $i_index)
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlComboLimitText

Function Reference

_GUICtrlComboLimitText

Limit the length of the text the user may type into the edit control of a combo box

#Include <GuiCombo.au3>
_GUICtrlComboLimitText ( $h_combobox [, $i_limit=0] )

Parameters

$h_combobox | control id/control hWnd
$i_limit | Optional: Specifies the maximum number of characters the user can enter

Return Value

None.

Remarks

If the $i_limit parameter is zero, the text length is limited to 0x7FFFFFFE characters.

If the combo box does not have the $CBS_AUTOHSCROLL style, setting the text limit to
be larger than the size of the edit control has no effect.

The $CB_LIMITTEXT message limits only the text the user can enter.

It has no effect on any text already in the edit control when the message is sent,
nor does it affect the length of the text copied to the edit control when a string
in the list box is selected.

The default limit to the text a user can enter in the edit control is 30,000 characters

Related

None.

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Combo,$Btn_Exit,$msg

GuiCreate("ComboBox Limit Text", 392, 254)

$Combo = GuiCtrlCreateCombo("", 70, 100, 270, 100,$CBS_SIMPLE)
GUICtrlSetData($Combo,"A|B|C|D|E|F")
_GUICtrlComboLimitText($Combo,10)
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 200, 90, 30)

GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
EndSelect
WEnd
Exit


Function _GUICtrlComboResetContent

Function Reference

_GUICtrlComboResetContent

Remove all items from the list box and edit control of a combo box

#Include <GuiCombo.au3>
_GUICtrlComboResetContent ( $h_combobox )

Parameters

$h_combobox control id/control hWnd

Return Value

None.

Remarks

None.

Related

_GUICtrlComboAddString, _GUICtrlComboDeleteString, _GUICtrlComboInsertString

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Combo,$ret,$Btn_Exit,$msg,$allocated,$Btn_Clear

GuiCreate("ComboBox Reset Content", 392, 254)

$Combo = GuiCtrlCreateCombo("", 70, 10, 270, 100,$CBS_SIMPLE)
$allocated = _GUICtrlComboInitStorage($Combo, 26, 50)
$ret = _GUICtrlComboAddDir($Combo,"drives")
$Btn_Clear = GUICtrlCreateButton("Reset Content",150,140,90,30)
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_Clear
_GUICtrlComboResetContent($Combo)
EndSelect
WEnd
Exit


Function _GUICtrlComboSelectString

Function Reference

_GUICtrlComboSelectString

Search the list of a combo box for an item that begins with the characters in a specified string

#Include <GuiCombo.au3>
_GUICtrlComboSelectString ( $h_combobox, $i_index, $s_search )

Parameters

$h_combobox | control id/control hWnd
$i_index | Specifies the zero-based index of the item preceding the first item to be searched
$s_search | string that contains the characters for which to search

Return Value

Success: | Returns the index of the selected item.
Failure: | Returns $CB_ERR if the search is unsuccessful and the current selection is not changed.

Remarks

When the search reaches the bottom of the list, it continues from the top
of the list back to the item specified by the wParam parameter.

If $i_index is –1, the entire list is searched from the beginning

A string is selected only if the characters from the starting point
match the characters in the prefix string

Related

_GUICtrlComboFindString

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Label,$Input,$Btn_Search,$Combo,$Btn_Exit,$Status,$msg,$ret

GuiCreate("ComboBox Select String", 392, 254)

$Label = GuiCtrlCreateLabel("Enter Search String", 20, 20, 120, 20)
$Input = GuiCtrlCreateInput("", 160, 20, 180, 20)
$Btn_Search = GuiCtrlCreateButton("Search", 160, 50, 90, 30)
$Combo = GuiCtrlCreateCombo("", 70, 100, 270, 100,$CBS_SIMPLE)
GUICtrlSetData($Combo,"AutoIt|v3|is|freeware|BASIC-like|scripting|language")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 200, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_Search
If(StringLen(GUICtrlRead($Input)) > 0) Then
$ret = _GUICtrlComboSelectString($Combo,-1,GUICtrlRead($Input))
If($ret <> $CB_ERR) Then
GUICtrlSetData($Status,'Found "' & GUICtrlRead($Input) & '" at index: ' & $ret)
Else
GUICtrlSetData($Status,'"' & GUICtrlRead($Input) & '" Not Found')
EndIf
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlComboSetCurSel

Function Reference

_GUICtrlComboSetCurSel

Select a string in the list of a combo box

#Include <GuiCombo.au3>
_GUICtrlComboSetCurSel ( $h_combobox, $i_index )

Parameters

$h_combobox | control id/control hWnd
$i_index | Specifies the zero-based index of the string to select

Return Value

Success: | Returns the index of the item selected.
Failure: | Returns $CB_ERR if $i_index is greater than the number of items in the list or if $i_index is –1 and the selection is cleared.
 | Returns $CB_ERRSPACE if there is insufficient space to store the new strings.

Remarks

If this $i_index is –1, any current selection in the list is removed and the edit control is cleared

Related

_GUICtrlComboGetCurSel

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Label,$Input,$Btn_Set,$Combo,$Btn_Exit,$msg,$ret

GuiCreate("ComboBox Set Cur Sel", 392, 254)

$Label = GuiCtrlCreateLabel("Enter Index to Set", 20, 20, 120, 20)
$Input = GuiCtrlCreateInput("", 160, 20, 180, 20,$ES_NUMBER)
GUICtrlSetLimit($Input,1)
$Btn_Set = GuiCtrlCreateButton("Set Cur Sel", 160, 50, 90, 30)
$Combo = GuiCtrlCreateCombo("", 70, 100, 270, 100,$CBS_SIMPLE)
GUICtrlSetData($Combo,"AutoIt|v3|is|freeware|BASIC-like|scripting|language")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 200, 90, 30)
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_Set
If(StringLen(GUICtrlRead($Input)) > 0) Then
$ret = _GUICtrlComboSetCurSel($Combo,Int(GUICtrlRead($Input)))
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlComboSetDroppedWidth

Function Reference

_GUICtrlComboSetDroppedWidth

Set the maximum allowable width

#Include <GuiCombo.au3>
_GUICtrlComboSetDroppedWidth ( $h_combobox, $i_width )

Parameters

$h_combobox | control id/control hWnd
$i_width | Specifies the width of the list box, in pixels

Return Value

Success: | Returns the new width of the list box.
Failure: | Returns $CB_ERR.

Remarks

Requirement: CBS_DROPDOWN or CBS_DROPDOWNLIST style

Related

_GUICtrlComboGetDroppedWidth, _GUICtrlComboGetDroppedState

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Label,$Input,$Btn_Set,$Combo,$Btn_Exit,$msg,$ret

GuiCreate("ComboBox Set Dropped Width", 392, 254)

$Label = GuiCtrlCreateLabel("Enter New Width", 20, 20, 100, 20)
$Input = GuiCtrlCreateInput("", 160, 20, 180, 20,$ES_NUMBER)
GUICtrlSetLimit($Input,3)
$Btn_Set = GuiCtrlCreateButton("Set Width", 160, 50, 90, 30)
$Combo = GuiCtrlCreateCombo("", 70, 100, 50, 120)
GUICtrlSetData($Combo,"AutoIt|v3|is|freeware|BASIC-like|scripting|language")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 200, 90, 30)
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_Set
If(StringLen(GUICtrlRead($Input)) > 0) Then
$ret = _GUICtrlComboSetDroppedWidth($Combo,Int(GUICtrlRead($Input)))
If($ret == $CB_ERR) Then
MsgBox(0,"Error","Couldn't set width")
EndIf
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlComboSetEditSel

Function Reference

_GUICtrlComboSetEditSel

Select characters in the edit control of a combo box

#Include <GuiCombo.au3>
_GUICtrlComboSetEditSel ( $h_combobox, $i_start, $i_stop )

Parameters

$h_combobox | control id/control hWnd
$i_start | starting position
$i_stop | ending position

Return Value

Success: | Returns TRUE.
Failure: | Returns $CB_ERR if the message is sent to a combo box with the $CBS_DROPDOWNLIST style.
 | Returns $CB_ERRSPACE if there is insufficient space to store the new strings.

Remarks

The positions are zero-based.

The first character of the edit control is in the zero position.

The first character after the last selected character is in the ending position.

For example, to select the first four characters of the edit control,
use a starting position of 0 and an ending position of 4

Related

_GUICtrlComboGetLBTextLen

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Combo,$Btn_Exit,$msg,$Btn_Sel

GuiCreate("ComboBox Set Edit Sel", 392, 254)

$Combo = GuiCtrlCreateCombo("", 70, 10, 270, 100,$CBS_SIMPLE)
GUICtrlSetData($Combo,"AutoIt|v3|is|freeware|BASIC-like|scripting|language","freeware")
$Btn_Sel = GUICtrlCreateButton("Select 1st 4 chars",150,150,90,30)
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 200, 90, 30)

GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_Sel
_GUICtrlComboSetEditSel($Combo,0,4)
EndSelect
WEnd
Exit


Function _GUICtrlComboSetExtendedUI

Function Reference

_GUICtrlComboSetExtendedUI

Select either the default user interface or the extended user interface

#Include <GuiCombo.au3>
_GUICtrlComboSetExtendedUI ( $h_combobox, $i_bool )

Parameters

$h_combobox | control id/control hWnd
$i_bool | Specifies whether the combo box uses the extended user interface or the default user interface

Return Value

Success: | Returns $CB_OKAY.
Failure: | Returns $CB_ERR if an error occurs.

Remarks

By default, the F4 key opens or closes the list and the
DOWN ARROW changes the current selection. In the extended
user interface, the F4 key is disabled and the DOWN ARROW
key opens the drop-down list

$i_bool specifies whether the combo box uses the extended
user interface or the default user interface.

A value of TRUE selects the extended user interface

A value of FALSE selects the standard user interface

Related

_GUICtrlComboGetExtendedUI

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Combo,$Btn_Exit,$Status,$msg,$Btn_Standard,$Btn_Extended,$state,$current

GuiCreate("ComboBox Set Extended UI", 392, 254)

$Combo = GuiCtrlCreateCombo("", 70, 10, 270, 120)
GUICtrlSetData($Combo,"AutoIt|v3|is|freeware|BASIC-like|scripting|language")
$Btn_Standard = GuiCtrlCreateButton("Standard", 75, 90, 90, 30)
$Btn_Extended = GuiCtrlCreateButton("Extended", 200, 90, 90, 30)
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))
$current = Not $state
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_Standard
_GUICtrlComboSetExtendedUI($Combo, 0)
Case $msg = $Btn_Extended
_GUICtrlComboSetExtendedUI($Combo, 1)
Case Else
$state = _GUICtrlComboGetExtendedUI($Combo)
If($state And $state <> $current) Then
$current = $state
GUICtrlSetData($Status,"Extend UI: True")
ElseIf($state <> $current) Then
$current = $state
GUICtrlSetData($Status,"Extend UI: False")
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlComboSetHorizontalExtent

Function Reference

_GUICtrlComboSetHorizontalExtent

Set the width, in pixels

#Include <GuiCombo.au3>
_GUICtrlComboSetHorizontalExtent ( $h_combobox, $i_width )

Parameters

$h_combobox | control id/control hWnd
$i_width | Specifies the scrollable width of the list box, in pixels

Return Value

None.

Remarks

An application sends the $CB_SETHORIZONTALEXTENT message to set the width,
in pixels, by which a list box can be scrolled horizontally (the scrollable width).

If the width of the list box is smaller than this value, the horizontal scroll bar
horizontally scrolls items in the list box.

If the width of the list box is equal to or greater than this value, the horizontal
scroll bar is hidden or, if the combo box has the $CBS_DISABLENOSCROLL style, disabled.

Related

_GUICtrlComboGetHorizontalExtent

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Combo,$Btn_Exit,$Status,$msg

GuiCreate("ComboBox Set Horizontal Extent", 392, 254)

$Combo = GuiCtrlCreateCombo("", 70, 10, 100, 150,BitOR($CBS_SIMPLE,$CBS_DISABLENOSCROLL,$WS_HSCROLL))
GUICtrlSetData($Combo,"AutoIt v3 is freeware BASIC-like scripting language designed for automating the Windows GUI.|" & _
"It uses a combination of simulated keystrokes mouse movement and window/control manipulation|" & _
"in order to automate tasks in a way not possible or reliable with other languages|" & _
"(e.g. VBScript and SendKeys).")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
$Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER))
_GUICtrlComboSetHorizontalExtent($Combo, 500)
GUICtrlSetData($Status,"Horizontal Extent: " & _GUICtrlComboGetHorizontalExtent($Combo))
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
EndSelect
WEnd
Exit


Function _GUICtrlComboSetItemHeight

Function Reference

_GUICtrlComboSetItemHeight

Set the height of list items or the selection field in a combo box

#Include <GuiCombo.au3>
_GUICtrlComboSetItemHeight ( $h_combobox, $i_component, $i_height )

Parameters

$h_combobox | control id/control hWnd
$i_component | Specifies the component of the combo box for which to set the height
$i_height | Specifies the height, in pixels, of the combo box component identified by $i_component

Return Value

Success: | Returns $CB_OKAY.
Failure: | Returns $CB_ERR if the index or height is invalid.

Remarks

$i_component parameter must be –1 to set the height of the selection field.

It must be zero to set the height of list items, unless the combo box has
the CBS_OWNERDRAWVARIABLE style. In that case, the $i_component parameter
is the zero-based index of a specific list item

Related

_GUICtrlComboGetItemHeight

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt ('MustDeclareVars', 1)

Dim $Height = 25, $Btn_Set, $Combo, $Btn_Exit, $msg, $ret

GUICreate("ComboBox Set Item Height", 392, 254)

$Combo = GUICtrlCreateCombo("", 70, 10, 270, 120)
GUICtrlSetData($Combo, "AutoIt|v3|is|freeware|BASIC-like|scripting|language")
$Btn_Set = GUICtrlCreateButton("Set", 150, 140, 90, 30)
$Btn_Exit = GUICtrlCreateButton("Exit", 150, 180, 90, 30)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_Set
$ret = _GUICtrlComboSetItemHeight ($Combo, -1, $Height)
If ($Height == 25) Then
$Height = 15
Else
$Height = 25
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlComboSetMinVisible

Function Reference

_GUICtrlComboSetMinVisible

Set the minimum number of visible items in the drop-down list of a combo box

#Include <GuiCombo.au3>
_GUICtrlComboSetMinVisible ( $h_combobox, $i_minimum )

Parameters

$h_combobox | control id/control hWnd
$i_minimum | Specifies the minimum number of visible items

Return Value

Success: | Returns TRUE.
Failure: | Returns FALSE otherwise.

Remarks

When the number of items in the drop-down list is greater than the minimum,
the combo box uses a scrollbar.

By default, 30 is the minimum number of visible items.

This message is ignored if the combo box control has style $CBS_NOINTEGRALHEIGHT.

To use $CB_SETMINVISIBLE, the application must specify comctl32.dll version 6 in the manifest

Related

_GUICtrlComboGetMinVisible

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt ('MustDeclareVars', 1)

Dim $Min = 5, $Combo, $ret, $Btn_Exit, $msg, $ret, $Btn_Set

GUICreate("ComboBox Set Min Visible", 392, 254)

$Combo = GUICtrlCreateCombo("", 70, 10, 270, 120)
$ret = _GUICtrlComboAddDir ($Combo, "drives")
$Btn_Set = GUICtrlCreateButton("Set", 150, 160, 90, 30)
$Btn_Exit = GUICtrlCreateButton("Exit", 150, 200, 90, 30)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_Set
_GUICtrlComboSetMinVisible ($Combo, $Min)
If ($Min == 5) Then
$Min = 30
Else
$Min = 5
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlComboSetTopIndex

Function Reference

_GUICtrlComboSetTopIndex

Ensure that a particular item is visible

#Include <GuiCombo.au3>
_GUICtrlComboSetTopIndex ( $h_combobox, $i_index )

Parameters

$h_combobox | control id/control hWnd
$i_index | Specifies the zero-based index of the list item

Return Value

Success: | Returns 0.
Failure: | Returns $CB_ERR.

Remarks

The system scrolls the list box contents so that either the specified
item appears at the top of the list box or the maximum scroll range
has been reached

Related

_GUICtrlComboGetTopIndex

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Combo,$ret,$Btn_Exit,$msg,$ret,$Label,$Input,$Btn_Set

GuiCreate("ComboBox Set Top Index", 392, 254)

$Label = GuiCtrlCreateLabel("Enter Top Index", 80, 20, 120, 20)
$Input = GuiCtrlCreateInput("", 160, 20, 50, 20,$ES_NUMBER)
GUICtrlSetLimit($Input,2)
$Btn_Set = GuiCtrlCreateButton("Set", 160, 50, 90, 30)
$Combo = GuiCtrlCreateCombo("", 70, 100, 270, 80,BitOR($CBS_SIMPLE,$CBS_DISABLENOSCROLL,$WS_VSCROLL))
$ret = _GUICtrlComboAddDir($Combo,"drives")
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 200, 90, 30)
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_Set
If(StringLen(GUICtrlRead($Input)) > 0) Then
_GUICtrlComboSetTopIndex($Combo,Int(GUICtrlRead($Input)))
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlComboShowDropDown

Function Reference

_GUICtrlComboShowDropDown

Show or hide the list box of a combo box

#Include <GuiCombo.au3>
_GUICtrlComboShowDropDown ( $h_combobox, $i_bool )

Parameters

$h_combobox | control id/control hWnd
$i_bool | Specifies whether the drop-down list box is to be shown or hidden

Return Value

None.

Remarks

Requirement: $CBS_DROPDOWN or $CBS_DROPDOWNLIST style

$i_bool = TRUE shows the list box
$i_bool = FALSE hides it

This message has no effect on a combo box created with the $CBS_SIMPLE style

Related

_GUICtrlComboGetDroppedState, _GUICtrlComboGetDroppedWidth, _GUICtrlComboSetDroppedWidth

Example

#include <GuiConstants.au3>
#include <GuiCombo.au3>

Opt('MustDeclareVars',1)

Dim $Label,$Input,$Btn_Show,$Btn_Hide,$Combo,$Btn_Exit,$msg,$ret

GuiCreate("ComboBox Show Dropdown", 392, 254)

$Combo = GuiCtrlCreateCombo("", 70, 10, 270, 120)
GUICtrlSetData($Combo,"AutoIt|v3|is|freeware|BASIC-like|scripting|language")
$Btn_Show = GuiCtrlCreateButton("Show", 80, 140, 90, 30)
$Btn_Hide = GuiCtrlCreateButton("Hide", 220, 140, 90, 30)
$Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30)
GuiSetState()
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_Show
_GUICtrlComboShowDropDown($Combo,1)
Case $msg = $Btn_Hide
_GUICtrlComboShowDropDown($Combo,0)
EndSelect
WEnd
Exit


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: GuiEdit Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_GUICtrlEditCanUndo | Determines whether there are any actions in an edit control's undo queue.
_GUICtrlEditEmptyUndoBuffer | Resets the undo flag of an edit control.
_GuiCtrlEditFind | Find/Replace text in an Edit control
_GUICtrlEditGetFirstVisibleLine | Retrieves the zero-based index of the uppermost visible line in a multiline edit control.
_GUICtrlEditGetLine | Copies a line of text from an edit control.
_GUICtrlEditGetLineCount | Retrieves the number of lines in a multiline edit control.
_GUICtrlEditGetModify | Retrieves the state of an edit control's modification flag.
_GUICtrlEditGetRECT | Retrieves the formatting rectangle of an edit control.
_GUICtrlEditGetSel | Retrieves the starting and ending character positions of the current selection in an edit control.
_GUICtrlEditLineFromChar | Retrieves the index of the line that contains the specified character index in a multiline edit control.
_GUICtrlEditLineIndex | Retrieves the character index of the first character of a specified line in a multiline edit control.
_GUICtrlEditLineLength | Retrieves the length, in characters, of a line in an edit control.
_GUICtrlEditLineScroll | Scrolls the text in a multiline edit control.
_GUICtrlEditReplaceSel | Replaces the current selection in an edit control with the specified text.
_GUICtrlEditScroll | Scrolls the text vertically in a multiline edit control.
_GUICtrlEditSetModify | Sets or clears the modification flag for an edit control.
_GUICtrlEditSetRECT | Sets the formatting rectangle of an edit control.
_GUICtrlEditSetSel | Selects a range of characters in an edit control.
_GUICtrlEditUndo | Undoes the last edit control operation in the control's undo queue.


Function _GUICtrlEditCanUndo

Function Reference

_GUICtrlEditCanUndo

Determines whether there are any actions in an edit control's undo queue.

#Include <GuiEdit.au3>
_GUICtrlEditCanUndo ( $h_edit )

Parameters

$h_edit control id/control hWnd

Return Value

Success: | Returns nonzero, if there are actions in the control's undo queue.
Failure: | Returns zero, if the undo queue is empty.

Remarks

If the undo queue is not empty, you can call the _GUICtrlEditUndo
to undo the most recent operation.

Related

_GUICtrlEditEmptyUndoBuffer, _GUICtrlEditGetModify, _GUICtrlEditReplaceSel, _GUICtrlEditSetModify, _GUICtrlEditUndo

Example

#include <GUIConstants.au3>
#include <GuiEdit.au3>

opt('MustDeclareVars', 1)

Dim $myedit, $ret, $Status, $msg, $current

GUICreate("Edit Can Undo", 392, 254)

$myedit = GUICtrlCreateEdit("First line" & @CRLF, 176, 32, 121, 97, $ES_AUTOVSCROLL + $WS_VSCROLL)

$Status = GUICtrlCreateLabel("Nothing to Undo", 0, 234, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
$ret = _GUICtrlEditCanUndo ($myedit)
If ($ret <> $current) Then
If ($ret == 0) Then
GUICtrlSetData($Status, "Nothing to Undo")
Else
GUICtrlSetData($Status, "Undo Available")
EndIf
$current = $ret
EndIf
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd


Function _GUICtrlEditEmptyUndoBuffer

Function Reference

_GUICtrlEditEmptyUndoBuffer

Resets the undo flag of an edit control.

#Include <GuiEdit.au3>
_GUICtrlEditEmptyUndoBuffer ( $h_edit )

Parameters

$h_edit control id/control hWnd

Return Value

None.

Remarks

The undo flag is automatically reset whenever the edit control receives a WM_SETTEXT or EM_SETHANDLE message.
The control can only undo or redo the most recent operation.

Related

_GUICtrlEditCanUndo, _GUICtrlEditGetModify, _GUICtrlEditReplaceSel, _GUICtrlEditSetModify, _GUICtrlEditUndo

Example

#include <GUIConstants.au3>
#include <GuiEdit.au3>

opt('MustDeclareVars', 1)

Dim $myedit, $ret, $Status, $msg, $current, $Btn_Empty

GUICreate("Edit Empty Undo Buffer", 392, 254)

$myedit = GUICtrlCreateEdit("First line" & @CRLF, 140, 32, 121, 97, $ES_AUTOVSCROLL + $WS_VSCROLL)
$Btn_Empty = GUICtrlCreateButton("Emtpy Buffer", 150, 150)
$Status = GUICtrlCreateLabel("Nothing to Undo", 0, 234, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
$ret = _GUICtrlEditCanUndo ($myedit)
If ($ret <> $current) Then
If ($ret == 0) Then
GUICtrlSetData($Status, "Nothing to Undo")
Else
GUICtrlSetData($Status, "Undo Available")
EndIf
$current = $ret
EndIf
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Btn_Empty
_GUICtrlEditEmptyUndoBuffer ($myedit)
EndSelect
WEnd


Function _GUICtrlEditFind

Function Reference

_GUICtrlEditFind

Find/Replace text in an Edit control

#Include <GuiEdit.au3>
_GUICtrlEditFind ( ByRef $h_gui, ByRef $h_edit [, $b_replace = False [, $s_WinTitle = "" [, $s_WinText = ""]]] )

Parameters

h_gui | GUI ID/Window Handle (Handle only be used with external controls)
$h_edit | control ID/Control Handle (Handle only be used with external controls)
$b_replace | Optional: Boolean True/False show replace option (Default is False)
$s_WinTitle | Optional: Window Title (should only be used with external controls)
$s_WinText | Optional: Window Text (should only be used with external controls)

Return Value

Remarks

Be careful using the $s_WinText
If you use text from the edit control and that text gets replaced
the function will no longer function correctly

Related

_GUICtrlEditReplaceSel, _GUICtrlEditGetSel, _GUICtrlEditSetSel

Example

Opt("MustDeclareVars", 1)
#include <GUIConstants.au3>
#include <GuiEdit.au3>

; *******************************************************
; Example 1 - Using with an AutoIt Created Edit control
; *******************************************************

_UseAutoItControl()

Func _UseAutoItControl()
Local $s_texttest = "this is a test" & @CRLF & _
"this is only a test" & @CRLF & _
"this testing should work for you as well as it does for me"
Local $GuiCtrlEditSearch, $myEdit, $Button1, $Button2, $msg

$GuiCtrlEditSearch = GUICreate('Find And Replace Example with AutoIt ' & FileGetVersion(@AutoItExe), 622, 448, 192, 125)
$myEdit = GUICtrlCreateEdit($s_texttest, 64, 24, 505, 233, _
BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_MULTILINE, $WS_HSCROLL, $ES_NOHIDESEL))
$Button1 = GUICtrlCreateButton("Find", 176, 288, 121, 33, 0)
$Button2 = GUICtrlCreateButton("Find And Replace", 368, 288, 121, 33, 0)
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Button1
_GUICtrlEditFind ($GuiCtrlEditSearch, $myEdit)
Case $msg = $Button2
_GUICtrlEditFind ($GuiCtrlEditSearch, $myEdit, True)
Case Else
;;;;;;;
EndSelect
WEnd
GUIDelete()
EndFunc ;==>_UseAutoItControl

; *******************************************************
; Example 2 - Using with an external Edit control
; *******************************************************

_UseExternalControl()

Func _UseExternalControl()
Local $s_texttest = 'Find And Replace Example with AutoIt ' & FileGetVersion(@AutoItExe) & @LF & _
"this is a test" & @LF & _
"this is only a test" & @LF & _
"this testing should work for you as well as it does for me"
Local $whandle, $handle
Local $Title = "Untitled - Notepad"

Run("notepad", "", @SW_MAXIMIZE)
;Wait for the window "Untitled" to exist
WinWait($Title)

; Get the handle of a notepad window
$whandle = WinGetHandle($Title)
If @error Then
MsgBox(4096, "Error", "Could not find the correct window")
Else
$handle = ControlGetHandle($whandle, "", "Edit1")
If @error Then
MsgBox(4096, "Error", "Could not find the correct control")
Else
; Send some text directly to this window's edit control
ControlSend($whandle, "", "Edit1", $s_texttest)
_GUICtrlEditFind ($whandle, $handle, True, $Title)
EndIf
EndIf
EndFunc ;==>_UseExternalControl


Function _GUICtrlEditGetFirstVisibleLine

Function Reference

_GUICtrlEditGetFirstVisibleLine

Retrieves the zero-based index of the uppermost visible line in a multiline edit control.

#Include <GuiEdit.au3>
_GUICtrlEditGetFirstVisibleLine ( $h_edit )

Parameters

$h_edit control id/control hWnd

Return Value

The return value is the zero-based index of the uppermost visible line in a multiline edit control.
For single-line edit controls, the return value is the zero-based index of the first visible character.

Remarks

The number of lines and the length of the lines in an edit control
depend on the width of the control and the current Wordwrap setting.

Related

_GUICtrlEditLineFromChar, _GUICtrlEditLineIndex, _GUICtrlEditLineScroll, _GUICtrlEditScroll

Example

#include <GUIConstants.au3>
#include <GuiEdit.au3>

opt('MustDeclareVars', 1)

Dim $myedit, $Status, $msg, $Btn_get

GUICreate("Edit Get First Visible Line", 392, 254)

$myedit = GUICtrlCreateEdit("First line" & @CRLF, 140, 32, 121, 97, $ES_AUTOVSCROLL + $WS_VSCROLL)
$Btn_get = GUICtrlCreateButton("Get", 150, 150)
$Status = GUICtrlCreateLabel("", 0, 234, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

; will be append dont' forget 3rd parameter
GUICtrlSetData($myedit, "2nd line" & @CRLF & "3rd line" & @CRLF & "4th line" & @CRLF & _
"5th line" & @CRLF & "6th line" & @CRLF & "7th line" & @CRLF & "8th line" & @CRLF & "9th line", 1)

GUISetState()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Btn_get
GUICtrlSetData($Status, "First Visible Line: " & _GUICtrlEditGetFirstVisibleLine ($myedit))
EndSelect
WEnd


Function _GUICtrlEditGetLine

Function Reference

_GUICtrlEditGetLine

Copies a line of text from an edit control.

#Include <GuiEdit.au3>
_GUICtrlEditGetLine(ByRef $h_edit, $i_line)

Parameters

$h_edit | controlID
$i_line | Specifies the line to be retrieved.

Return Value

Returns the line from the multiline edit control.
If an error occurs, the return value is "" (empty string) and @error is set.

Remarks

None.

Related

_GUICtrlEditLineIndex, _GUICtrlEditLineLength

Example

#include <GUIConstants.au3>
#include <GuiEdit.au3>

opt('MustDeclareVars', 1)

Dim $myedit, $Status, $msg, $Btn_GET
Dim $s_text = "AutoIt v3 is a freeware BASIC-like scripting language" & @CRLF & _
"designed for automating the Windows GUI." & @CRLF & _
"It uses a combination of simulated keystrokes," & @CRLF & _
"mouse movement and window/control manipulation" & @CRLF & _
"in order to automate tasks in a way not possible" & @CRLF & _
"or reliable with other languages (e.g. VBScript and SendKeys)."

;================================================================
; Example 1 - Get Line using AutoIt Control
;================================================================
GUICreate("Edit Get Line", 392, 254)

$myedit = GUICtrlCreateEdit($s_text, 140, 32, 121, 97, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $WS_VSCROLL, $WS_HSCROLL, $ES_MULTILINE))
GUICtrlSetLimit($myedit, 1500)
$Status = GUICtrlCreateLabel("", 0, 234, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
$Btn_GET = GUICtrlCreateButton("Get Line 3", 150, 130, 90, 40, $BS_MULTILINE)

GUISetState()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Btn_GET
Local $line = _GUICtrlEditGetLine($myedit, 3)
If @error == $EC_ERR Then
GUICtrlSetData($Status, "Line: Invalid")
Else
GUICtrlSetData($Status, "Line: " & $line)
EndIf
EndSelect
WEnd
GUIDelete()

;================================================================
; Example 2 - Get Line using external Control
;================================================================
Run("Notepad")
WinWait("Untitled - Notepad")
$myedit = ControlGetHandle("Untitled - Notepad", "", "Edit1")
ControlSetText("Untitled - Notepad","", "Edit1", $s_Text)
MsgBox(0,"Line 4", _GUICtrlEditGetLine($myedit, 4))


Function _GUICtrlEditGetLineCount

Function Reference

_GUICtrlEditGetLineCount

Retrieves the number of lines in a multiline edit control.

#Include <GuiEdit.au3>
_GUICtrlEditGetLineCount ( $h_edit )

Parameters

$h_edit control id/control hWnd

Return Value

The return value is an integer specifying the total number of text lines in the multiline edit control.

Remarks

If the control has no text, the return value is 1.
The return value will never be less than 1.

The _GUICtrlEditGetLineCount retrieves the total number of text lines,
not just the number of lines that are currently visible.

If the Wordwrap feature is enabled, the number of lines can change when the dimensions of the editing window change.

Related

_GUICtrlEditGetFirstVisibleLine, _GUICtrlEditLineFromChar, _GUICtrlEditLineIndex

Example

#include <GUIConstants.au3>
#include <GuiEdit.au3>

opt('MustDeclareVars', 1)

Dim $myedit, $Status, $msg

GUICreate("Edit Get Line Count", 392, 254)

$myedit = GUICtrlCreateEdit("First line" & @CRLF, 140, 32, 121, 97, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_MULTILINE))
GUICtrlSetLimit($myedit, 1500)
$Status = GUICtrlCreateLabel("", 0, 234, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

; will be append dont' forget 3rd parameter
GUICtrlSetData($myedit, "2nd line" & @CRLF & "3rd line" & @CRLF & "4th line" & @CRLF & _
"5th line" & @CRLF & "6th line" & @CRLF & "7th line" & @CRLF & "8th line" & @CRLF & "9th line", 1)

GUISetState()
GUICtrlSetData($Status, "Line Count: " & _GUICtrlEditGetLineCount ($myedit))

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd


Function _GUICtrlEditGetModify

Function Reference

_GUICtrlEditGetModify

Retrieves the state of an edit control's modification flag.

#Include <GuiEdit.au3>
_GUICtrlEditGetModify ( $h_edit )

Parameters

$h_edit control id/control hWnd

Return Value

Success: | Returns nonzero, if the contents of edit control have been modified.
Failure: | Returns 0 otherwise.

Remarks

The system automatically clears the modification flag to zero when the control is created.
If the user changes the control's text, the system sets the flag to nonzero.
You can call _GUICtrlEditSetModify to set or clear the flag.

Related

_GUICtrlEditCanUndo, _GUICtrlEditEmptyUndoBuffer, _GUICtrlEditSetModify, _GUICtrlEditUndo

Example

#include <GUIConstants.au3>
#include <GuiEdit.au3>

opt('MustDeclareVars', 1)

Dim $myedit, $ret, $Status, $msg, $current

GUICreate("Edit Get Modify", 392, 254)

$myedit = GUICtrlCreateEdit("First line" & @CRLF, 140, 32, 121, 97, $ES_AUTOVSCROLL + $WS_VSCROLL)

$Status = GUICtrlCreateLabel("Un-Modified", 0, 234, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
$ret = _GUICtrlEditGetModify ($myedit)
If ($ret <> $current) Then
If ($ret == 0) Then
GUICtrlSetData($Status, "Un-Modified")
Else
GUICtrlSetData($Status, "Modified")
EndIf
$current = $ret
EndIf
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd


Function _GUICtrlEditGetRECT

Function Reference

_GUICtrlEditGetRECT

Retrieves the formatting rectangle of an edit control.

#Include <GuiEdit.au3>
_GUICtrlEditGetRECT ( $h_edit )

Parameters

$h_edit controlID

Return Value

Success: | Returns an array containing the RECT, first element ($array[0]) contains the number of elements.
Failure: | Returns $EC_ERR, if an error occurs.

Remarks

Under certain conditions, _GUICtrlEditGetRECT might not return the exact values that
_GUICtrlEditSetRECT set—it will be approximately correct,
but it can be off by a few pixels.

Related

_GUICtrlEditSetRECT

Example

#include <GUIConstants.au3>
#include <GuiEdit.au3>

opt('MustDeclareVars', 1)

Dim $myedit, $s_rect, $label_rect, $msg, $rect_array

GUICreate("Edit Get RECT", 392, 254)

$myedit = GUICtrlCreateEdit("First line" & @CRLF, 10, 32, 121, 97, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL))

$s_rect = "Left:" & @LF & "Top:" & @LF & "Right:" & @LF & "Bottom:"
$label_rect = GUICtrlCreateLabel($s_rect, 145, 50, 100, 55, $SS_SUNKEN)

GUISetState()
$rect_array = _GUICtrlEditGetRECT ($myedit)
If ($rect_array == $EC_ERR) Then
MsgBox(0, "Error", "Unable to Get RECT")
ElseIf (IsArray($rect_array)) Then
$s_rect = "Left:" & $rect_array[1] & @LF & "Top:" & $rect_array[2] & @LF & "Right:" & $rect_array[3] & @LF & "Bottom:" & $rect_array[4]
GUICtrlSetData($label_rect, $s_rect)
EndIf

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd


Function _GUICtrlEditGetSel

Function Reference

_GUICtrlEditGetSel

Retrieves the starting and ending character positions of the current selection in an edit control.

#Include <GuiEdit.au3>
_GUICtrlEditGetSel ( $h_edit )

Parameters

$h_edit control id/control hWnd

Return Value

Success: | Returns an array containing the starting and ending selected positions, first element ($array[0]) contains the number of elements.
Failure: | Returns $EC_ERR if an error occurs.

Remarks

$array[1] contains the starting position
$array[2] contains the ending position

Related

_GUICtrlEditReplaceSel, _GUICtrlEditSetSel

Example

#include <GUIConstants.au3>
#include <GuiEdit.au3>

opt('MustDeclareVars', 1)

Dim $myedit, $Status, $msg, $Btn_GET, $a_sel

GUICreate("Edit Get Line Count", 392, 254)

$myedit = GUICtrlCreateEdit("First line" & @CRLF, 140, 32, 121, 97, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_MULTILINE))
GUICtrlSetLimit($myedit, 1500)
$Status = GUICtrlCreateLabel("", 0, 234, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
$Btn_GET = GUICtrlCreateButton("Get Sel", 150, 130, 90, 40, $BS_MULTILINE)

; will be append dont' forget 3rd parameter
GUICtrlSetData($myedit, "2nd line" & @CRLF & "3rd line" & @CRLF & "4th line" & @CRLF & _
"5th line" & @CRLF & "6th line" & @CRLF & "7th line" & @CRLF & "8th line" & @CRLF & "9th line", 1)

GUISetState()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Btn_GET
$a_sel = _GUICtrlEditGetSel ($myedit)
If ($a_sel == $EC_ERR) Then
GUICtrlSetData($Status, "Error getting sel positions")
ElseIf (IsArray($a_sel)) Then
GUICtrlSetData($Status, "Starting Pos: " & $a_sel[1] & " Ending Pos: " & $a_sel[2])
Else
GUICtrlSetData($Status, "")
EndIf
EndSelect
WEnd


Function _GUICtrlEditLineFromChar

Function Reference

_GUICtrlEditLineFromChar

Retrieves the index of the line that contains the specified character index in a multiline edit control.

#Include <GuiEdit.au3>
_GUICtrlEditLineFromChar ( $h_edit [, $i_index = -1] )

Parameters

$h_edit | control id/control hWnd
$i_index | Optional: Specifies the character index of the character contained in the line whose number is to be retrieved.

Return Value

The return value is the zero-based line number of the line containing the character index specified by $i_index.

Remarks

If $i_index is –1, _GUICtrlEditLineFromChar retrieves either the line number of the current line
(the line containing the caret) or, if there is a selection, the line number of the line containing
the beginning of the selection.

Related

_GUICtrlEditLineIndex

Example

#include <GUIConstants.au3>
#include <GuiEdit.au3>

opt('MustDeclareVars', 1)

Dim $myedit, $Status, $msg, $Btn_GET

GUICreate("Edit Line From Char", 392, 254)

$myedit = GUICtrlCreateEdit("First line" & @CRLF, 140, 32, 121, 97, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_MULTILINE))
GUICtrlSetLimit($myedit, 1500)
$Status = GUICtrlCreateLabel("", 0, 234, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
$Btn_GET = GUICtrlCreateButton("Get", 150, 130, 90, 40, $BS_MULTILINE)

; will be append dont' forget 3rd parameter
GUICtrlSetData($myedit, "2nd line" & @CRLF & "3rd line" & @CRLF & "4th line" & @CRLF & _
"5th line" & @CRLF & "6th line" & @CRLF & "7th line" & @CRLF & "8th line" & @CRLF & "9th line", 1)

GUISetState()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Btn_GET
GUICtrlSetData($Status, "Line From Char: " & _GUICtrlEditLineFromChar ($myedit))
EndSelect
WEnd


Function _GUICtrlEditLineIndex

Function Reference

_GUICtrlEditLineIndex

Retrieves the character index of the first character of a specified line in a multiline edit control.

#Include <GuiEdit.au3>
_GUICtrlEditLineIndex ( $h_edit [, $i_line = -1] )

Parameters

$h_edit | control id/control hWnd
$i_line | Optional: Specifies the zero-based line number. A value of –1 specifies the current line number (the line that contains the caret).

Return Value

Success: | Returns the character index of the line specified in the $i_line parameter.
Failure: | Returns $EC_ERR if the specified line number is greater than the number of lines in the edit control.

Remarks

None.

Related

_GUICtrlEditLineFromChar

Example

#include <GUIConstants.au3>
#include <GuiEdit.au3>

opt('MustDeclareVars', 1)

Dim $myedit, $Status, $msg, $Btn_GET

GUICreate("Edit Line Index", 392, 254)

$myedit = GUICtrlCreateEdit("First line" & @CRLF, 140, 32, 121, 97, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_MULTILINE))
GUICtrlSetLimit($myedit, 1500)
$Status = GUICtrlCreateLabel("", 0, 234, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
$Btn_GET = GUICtrlCreateButton("Get", 150, 130, 90, 40, $BS_MULTILINE)

; will be append dont' forget 3rd parameter
GUICtrlSetData($myedit, "2nd line" & @CRLF & "3rd line" & @CRLF & "4th line" & @CRLF & _
"5th line" & @CRLF & "6th line" & @CRLF & "7th line" & @CRLF & "8th line" & @CRLF & "9th line", 1)

GUISetState()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Btn_GET
Local $index = _GUICtrlEditLineIndex ($myedit)
If ($index == $EC_ERR) Then
GUICtrlSetData($Status, "Character Index: Invalid Index")
Else
GUICtrlSetData($Status, "Character Index: " & $index)
EndIf
EndSelect
WEnd


Function _GUICtrlEditLineLength

Function Reference

_GUICtrlEditLineLength

Retrieves the length, in characters, of a line in an edit control.

#Include <GuiEdit.au3>
_GUICtrlEditLineLength ( $h_edit [, $i_index = -1] )

Parameters

$h_edit | control id/control hWnd
$i_index | Optional: Specifies the character index of a character in the line whose length is to be retrieved.

Return Value

For multiline edit controls, the return value is the length, in TCHARs, of the line specified by the $i_index parameter.
For single-line edit controls, the return value is the length, in TCHARs, of the text in the edit control.

Remarks

$i_index
For ANSI text, this is the number of bytes
For Unicode text, this is the number of characters.
It does not include the carriage-return character at the end of the line.
If $i_index is greater than the number of characters in the control, the return value is zero.

Related

_GUICtrlEditGetLineCount

Example

#include <GUIConstants.au3>
#include <GuiEdit.au3>

opt('MustDeclareVars', 1)

Dim $myedit, $Status, $msg, $Btn_GET

GUICreate("Edit Line Length", 392, 254)

$myedit = GUICtrlCreateEdit("First line" & @CRLF, 140, 32, 121, 97, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_MULTILINE))
GUICtrlSetLimit($myedit, 1500)
$Status = GUICtrlCreateLabel("", 0, 234, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
$Btn_GET = GUICtrlCreateButton("Get", 150, 130, 90, 40, $BS_MULTILINE)

; will be append dont' forget 3rd parameter
GUICtrlSetData($myedit, "2nd line" & @CRLF & "3rd line" & @CRLF & "4th line" & @CRLF & _
"5th line" & @CRLF & "6th line" & @CRLF & "7th line" & @CRLF & "8th line" & @CRLF & "9th line", 1)

GUISetState()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Btn_GET
GUICtrlSetData($Status, "Line Length: " & _GUICtrlEditLineLength ($myedit))
EndSelect
WEnd


Function _GUICtrlEditLineScroll

Function Reference

_GUICtrlEditLineScroll

Scrolls the text in a multiline edit control.

#Include <GuiEdit.au3>
_GUICtrlEditLineScroll ( $h_edit, $i_horiz, $i_vert )

Parameters

$h_edit | control id/control hWnd
$i_horiz | Specifies the number of characters to scroll horizontally.
$i_vert | Specifies the number of lines to scroll vertically.

Return Value

Success: | Returns TRUE if the message is sent to a multiline edit control.
Failure: | Returns FALSE if the message is sent to a single-line edit control.

Remarks

The control does not scroll vertically past the last line of text in the edit control.
If the current line plus the number of lines specified by the $i_vert parameter exceeds the total number of lines in the edit control,
the value is adjusted so that the last line of the edit control is scrolled to the top of the edit-control window.

_GUICtrlEditLineScroll scrolls the text vertically or horizontally in a multiline edit control.
_GUICtrlEditLineScroll can be used to scroll horizontally past the last character of any line.

Related

_GUICtrlEditScroll

Example

#include <GUIConstants.au3>
#include <GuiEdit.au3>

opt('MustDeclareVars', 1)

Dim $myedit, $msg, $Btn_Scrollv, $Btn_Scrollh

GUICreate("Edit Line Scroll", 392, 254)

$myedit = GUICtrlCreateEdit("AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI." & @CRLF, 140, 32, 121, 97, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_MULTILINE, $WS_HSCROLL))
GUICtrlSetLimit($myedit, 1500)
$Btn_Scrollh = GUICtrlCreateButton("Scroll Horiz", 75, 140, 90, 30)
$Btn_Scrollv = GUICtrlCreateButton("Scroll Vert", 190, 140, 90, 30)

; will be append dont' forget 3rd parameter
GUICtrlSetData($myedit, "It uses a combination of simulated keystrokes, mouse movement and window/control manipulation" & @CRLF & _
"in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript" & @CRLF & _
"and SendKeys)." & @CRLF & _
'AutoIt was initially designed for PC "roll out" situations to configure thousands of PCs, but with the' & @CRLF & _
"arrival of v3 it is also well suited to performing home automation and the scripting of repetitive" & @CRLF & _
"tasks." & @CRLF & @CRLF & "AutoIt can:" & @CRLF & @CRLF & "Execute Windows and DOS executables", 1)

GUISetState()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Btn_Scrollv
_GUICtrlEditLineScroll ($myedit, 0, 1)
Case $msg = $Btn_Scrollh
_GUICtrlEditLineScroll ($myedit, 10, 0)
EndSelect
WEnd


Function _GUICtrlEditReplaceSel

Function Reference

_GUICtrlEditReplaceSel

Replaces the current selection in an edit control with the specified text.

#Include <GuiEdit.au3>
_GUICtrlEditReplaceSel ( $h_edit, $i_bool, $s_text )

Parameters

$h_edit | control id/control hWnd
$i_bool | Specifies whether the replacement operation can be undone. If this is TRUE, the operation can be undone. If this is FALSE , the operation cannot be undone.
$s_text | String containing the replacement text.

Return Value

None.

Remarks

Use the _GUICtrlEditReplaceSel to replace only a portion of the text in an edit control.
If there is no current selection, the replacement text is inserted at the current location of the caret.

Related

_GUICtrlEditGetSel, _GUICtrlEditSetSel

Example

#include <GUIConstants.au3>
#include <GuiEdit.au3>

opt('MustDeclareVars', 1)

Dim $myedit, $msg, $Btn_Replace

GUICreate("Edit Replace Sel", 392, 254)

$myedit = GUICtrlCreateEdit("AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI." & @CRLF, 140, 32, 121, 97, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_MULTILINE, $WS_HSCROLL))
GUICtrlSetLimit($myedit, 1500)
$Btn_Replace = GUICtrlCreateButton("Replace Sel", 150, 140, 90, 30)

; will be append dont' forget 3rd parameter
GUICtrlSetData($myedit, "It uses a combination of simulated keystrokes, mouse movement and window/control manipulation" & @CRLF & _
"in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript" & @CRLF & _
"and SendKeys)." & @CRLF & _
'AutoIt was initially designed for PC "roll out" situations to configure thousands of PCs, but with the' & @CRLF & _
"arrival of v3 it is also well suited to performing home automation and the scripting of repetitive" & @CRLF & _
"tasks." & @CRLF & @CRLF & "AutoIt can:" & @CRLF & @CRLF & "Execute Windows and DOS executables", 1)

GUISetState()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Btn_Replace
_GUICtrlEditReplaceSel ($myedit, 1, "Oops")
EndSelect
WEnd


Function _GUICtrlEditScroll

Function Reference

_GUICtrlEditScroll

Scrolls the text vertically in a multiline edit control.

#Include <GuiEdit.au3>
_GUICtrlEditScroll ( $h_edit, $i_direct )

Parameters

$h_edit | control id/control hWnd
$i_direct | Specifies the action the scroll bar is to take.

Return Value

Success: | Returns in the high-order word of the return value is TRUE, and in the low-order word is the number of lines that the command scrolls.
Failure: | Returns FALSE if the $i_direct parameter specifies an invalid value.

Remarks

$i_direct
This parameter can be one of the following values.

$SB_LINEDOWN | Scrolls down one line.
$SB_LINEUP | Scrolls up one line.
$SB_PAGEDOWN | Scrolls down one page.
$SB_PAGEUP | Scrolls up one page.
$SB_SCROLLCARET | Scrolls the caret into view

To scroll to a specific line or character position, use the _GUICtrlEditLineScroll.

Related

_GUICtrlEditLineScroll

Example

#include <GUIConstants.au3>
#include <GuiEdit.au3>

opt('MustDeclareVars', 1)

Dim $myedit, $msg, $Btn_linedown, $Btn_lineup, $Btn_pagedown, $Btn_pageup

GUICreate("Edit Scroll", 392, 254)

$myedit = GUICtrlCreateEdit("AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI." & @CRLF, 140, 32, 121, 97, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_MULTILINE, $WS_HSCROLL))
GUICtrlSetLimit($myedit, 1500)
$Btn_linedown = GUICtrlCreateButton("Line Down", 75, 140, 90, 30)
$Btn_lineup = GUICtrlCreateButton("Line Up", 75, 180, 90, 30)
$Btn_pagedown = GUICtrlCreateButton("Page Down", 190, 140, 90, 30)
$Btn_pageup = GUICtrlCreateButton("Page Up", 190, 180, 90, 30)

; will be append dont' forget 3rd parameter
GUICtrlSetData($myedit, "It uses a combination of simulated keystrokes, mouse movement and window/control manipulation" & @CRLF & _
"in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript" & @CRLF & _
"and SendKeys)." & @CRLF & _
'AutoIt was initially designed for PC "roll out" situations to configure thousands of PCs, but with the' & @CRLF & _
"arrival of v3 it is also well suited to performing home automation and the scripting of repetitive" & @CRLF & _
"tasks." & @CRLF & @CRLF & "AutoIt can:" & @CRLF & @CRLF & "Execute Windows and DOS executables", 1)

GUISetState()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Btn_linedown
_GUICtrlEditScroll ($myedit, $SB_LINEDOWN)
Case $msg = $Btn_lineup
_GUICtrlEditScroll ($myedit, $SB_LINEUP)
Case $msg = $Btn_pagedown
_GUICtrlEditScroll ($myedit, $SB_PAGEDOWN)
Case $msg = $Btn_pageup
_GUICtrlEditScroll ($myedit, $SB_PAGEUP)
EndSelect
WEnd


Function _GUICtrlEditSetModify

Function Reference

_GUICtrlEditSetModify

Sets or clears the modification flag for an edit control.

#Include <GuiEdit.au3>
_GUICtrlEditSetModify ( $h_edit, $i_bool )

Parameters

$h_edit | control id/control hWnd
$i_bool | Specifies the new value for the modification flag. A value of TRUE indicates the text has been modified. A value of FALSE indicates it has not been modified.

Return Value

None.

Remarks

The system automatically clears the modification flag to zero when the control is created.
If the user changes the control's text, the system sets the flag to nonzero.
You can use the _GUICtrlEditGetModify to retrieve the current state of the flag.

Related

_GUICtrlEditGetModify

Example

#include <GUIConstants.au3>
#include <GuiEdit.au3>

opt('MustDeclareVars', 1)

Dim $myedit, $ret, $Status, $msg, $current, $Btn_Set, $i_bool = 0

GUICreate("Edit Set Modify", 392, 254)

$myedit = GUICtrlCreateEdit("First line" & @CRLF, 140, 32, 121, 97, $ES_AUTOVSCROLL + $WS_VSCROLL)
$Btn_Set = GUICtrlCreateButton("Set", 150, 140, 90, 30)

$Status = GUICtrlCreateLabel("Un-Modified", 0, 234, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
$ret = _GUICtrlEditGetModify ($myedit)
If ($ret <> $current) Then
If ($ret == 0) Then
GUICtrlSetData($Status, "Un-Modified")
Else
GUICtrlSetData($Status, "Modified")
EndIf
$current = $ret
EndIf
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Btn_Set
$i_bool = Not $i_bool
_GUICtrlEditSetModify ($myedit, $i_bool)
EndSelect
WEnd


Function _GUICtrlEditSetRECT

Function Reference

_GUICtrlEditSetRECT

Sets the formatting rectangle of an edit control.

#Include <GuiEdit.au3>
_GUICtrlEditSetRECT (Byref $h_edit, $left, $top, $right, $bottom )

Parameters

$h_edit | controlID
$left | Specifies the x-coordinate of the upper-left corner of the rectangle.
$top | Specifies the y-coordinate of the upper-left corner of the rectangle.
$right | Specifies the x-coordinate of the lower-right corner of the rectangle.
$bottom | Specifies the y-coordinate of the lower-right corner of the rectangle.

Return Value

None

Remarks

None.

Related

_GUICtrlEditGetRECT

Example

#include <GUIConstants.au3>
#include <GuiEdit.au3>

Opt('MustDeclareVars', 1)

Dim $myedit, $Status, $msg, $s_rect, $label_rect, $rect_array, $btn_set

GUICreate("Edit Set Rect", 392, 254)
$myedit = GUICtrlCreateEdit("AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation" & @CRLF, 10, 32, 171, 97, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_MULTILINE))
GUICtrlSetLimit($myedit, 1500)
$label_rect = GUICtrlCreateLabel($s_rect, 195, 50, 100, 55, $SS_SUNKEN)
$btn_set = GUICtrlCreateButton("Set", 150, 150, 90, 40)
GUISetState()
$rect_array = _GUICtrlEditGetRECT($myedit)
If ($rect_array == $EC_ERR) Then
MsgBox(0, "Error", "Unable to Get RECT")
ElseIf (IsArray($rect_array)) Then
$s_rect = "Left:" & $rect_array[1] & @LF & "Top:" & $rect_array[2] & @LF & "Right:" & $rect_array[3] & @LF & "Bottom:" & $rect_array[4]
GUICtrlSetData($label_rect, $s_rect)
EndIf

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $btn_set
_GUICtrlEditSetRect($myedit, 0, 0, 80, $rect_array[4])
$rect_array = _GUICtrlEditGetRECT($myedit)
If ($rect_array == $EC_ERR) Then
MsgBox(0, "Error", "Unable to Get RECT")
ElseIf (IsArray($rect_array)) Then
$s_rect = "Left:" & $rect_array[1] & @LF & "Top:" & $rect_array[2] & @LF & "Right:" & $rect_array[3] & @LF & "Bottom:" & $rect_array[4]
GUICtrlSetData($label_rect, $s_rect)
EndIf
EndSelect
WEnd


Function _GUICtrlEditSetSel

Function Reference

_GUICtrlEditSetSel

Selects a range of characters in an edit control.

#Include <GuiEdit.au3>
_GUICtrlEditSetSel ( $h_edit, $i_start, $i_end )

Parameters

$h_edit | control id/control hWnd
$i_start | Specifies the starting character position of the selection.
$i_end | Specifies the ending character position of the selection.

Return Value

None.

Remarks

The start value can be greater than the end value.
The lower of the two values specifies the character position of the first character in the selection.
The higher value specifies the position of the first character beyond the selection.

The start value is the anchor point of the selection, and the end value is the active end.
If the user uses the SHIFT key to adjust the size of the selection, the active end can move but the anchor point remains the same.

If the $i_start is 0 and the $i_end is –1, all the text in the edit control is selected.
If the $i_start is –1, any current selection is deselected.

The control displays a flashing caret at the $i_end position regardless of the relative values of $i_start and $i_end.

Related

_GUICtrlEditGetSel

Example

#include <GUIConstants.au3>
#include <GuiEdit.au3>

opt('MustDeclareVars', 1)

Dim $myedit, $msg

GUICreate("Edit Set Sel", 392, 254)

$myedit = GUICtrlCreateEdit("AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI." & @CRLF, 140, 32, 121, 97, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_MULTILINE, $WS_HSCROLL))
GUICtrlSetLimit($myedit, 1500)

; will be append dont' forget 3rd parameter
GUICtrlSetData($myedit, "It uses a combination of simulated keystrokes, mouse movement and window/control manipulation" & @CRLF & _
"in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript" & @CRLF & _
"and SendKeys)." & @CRLF & _
'AutoIt was initially designed for PC "roll out" situations to configure thousands of PCs, but with the' & @CRLF & _
"arrival of v3 it is also well suited to performing home automation and the scripting of repetitive" & @CRLF & _
"tasks." & @CRLF & @CRLF & "AutoIt can:" & @CRLF & @CRLF & "Execute Windows and DOS executables", 1)

GUISetState()
_GUICtrlEditSetSel ($myedit, 0, 6)

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd


Function _GUICtrlEditUndo

Function Reference

_GUICtrlEditUndo

Undoes the last edit control operation in the control's undo queue.

#Include <GuiEdit.au3>
_GUICtrlEditUndo ( $h_edit )

Parameters

$h_edit control id/control hWnd

Return Value

Success: | Returns TRUE if the undo operation is successful.
Failure: | Returns FALSE if the undo operation fails.

Remarks

An undo operation can also be undone.
For example, you can restore deleted text with the first _GUICtrlEditUndo,
and remove the text again with a second _GUICtrlEditUndo as long as there
is no intervening edit operation.

Related

_GUICtrlEditCanUndo, _GUICtrlEditEmptyUndoBuffer, _GUICtrlEditGetModify

Example

#include <GUIConstants.au3>
#include <GuiEdit.au3>

opt('MustDeclareVars', 1)

Dim $myedit, $ret, $Status, $msg, $current, $Btn_Undo

GUICreate("Edit Undo", 392, 254)

$myedit = GUICtrlCreateEdit("First line" & @CRLF, 140, 32, 121, 97, $ES_AUTOVSCROLL + $WS_VSCROLL)
$Btn_Undo = GUICtrlCreateButton("Undo", 150, 150)
$Status = GUICtrlCreateLabel("Nothing to Undo", 0, 234, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
$ret = _GUICtrlEditCanUndo ($myedit)
If ($ret <> $current) Then
If ($ret == 0) Then
GUICtrlSetData($Status, "Nothing to Undo")
Else
GUICtrlSetData($Status, "Undo Available")
EndIf
$current = $ret
EndIf
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Btn_Undo
_GUICtrlEditUndo ($myedit)
EndSelect
WEnd


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: GuiIPAddress Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_GUICtrlIpAddressClear | Clears the contents of the IP address control
_GUICtrlIpAddressCreate | Create a GUI IP Address Control
_GUICtrlIpAddressDelete | Deletes the IpAddress control
_GUICtrlIpAddressGet | Retrieves the address values for all four fields in the IP address control
_GUICtrlIpAddressIsBlank | Determines if all fields in the IP address control are blank
_GUICtrlIpAddressSet | Sets the address values for all four fields in the IP address control
_GUICtrlIpAddressSetFocus | Sets the keyboard focus to the specified field in the IP address control.
_GUICtrlIpAddressSetFont | Set the font for the control
_GUICtrlIpAddressSetRange | Sets the valid range for the specified field in the IP address control
_GUICtrlIpAddressShowHide | Shows/Hides the IP address control


Function _GUICtrlIpAddressClear

Function Reference

_GUICtrlIpAddressClear

Clears the contents of the IP address control

#Include <GuiIPAddress.au3>
_GUICtrlIpAddressClear ( hwnd )

Parameters

hwnd handle to a GUI IP Address control

Return Value

Remarks

None

Related

_GUICtrlIpAddressSet

Example

#include <GuiIPAddress.au3>

Opt("MustDeclareVars", 1)

_Main()

Func _Main()
Local $msg, $hgui, $clear, $button, $hIPAddress

$hgui = GUICreate("IP Address Control Create Example", 300, 150)

$hIPAddress = _GUICtrlIpAddressCreate ($hgui, 10, 10, 125, 30, $WS_THICKFRAME)

$clear = GUICtrlCreateButton("Clear IP", 10, 50, 80, 20)

$button = GUICtrlCreateButton("Exit", 100, 100, 100, 25)

_GUICtrlIpAddressSet ($hIPAddress, "24.168.2.128")

GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()

Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $button
Exit
Case $msg = $clear
_GUICtrlIpAddressClear ($hIPAddress)
EndSelect
WEnd
EndFunc ;==>_Main


Function _GUICtrlIpAddressCreate

Function Reference

_GUICtrlIpAddressCreate

Create a GUI IP Address Control

#Include <GuiIPAddress.au3>
_GUICtrlIpAddressCreate ( hwnd, left, top, width, height [, style [, exstyles]] )

Parameters

hwnd | handle to a gui window
left | The left side of the control
top | The top of the control
width | The width of the control
height | The height of the control
style | [optional] defines the style of the control default (-1): none forced styles : $WS_CHILD, $WS_VISIBLE, $WS_TABSTOP
exstyles | [optional] Defines the extended style of the control default (-1): none

Return Value

Remarks

None

Related

Example

#include <GuiIPAddress.au3>

Opt("MustDeclareVars", 1)

_Main()

Func _Main()
Local $msg, $hgui, $button, $hIPAddress

$hgui = GUICreate("IP Address Control Create Example", 300, 150)

$hIPAddress = _GUICtrlIpAddressCreate ($hgui, 10, 10, 125, 30, $WS_THICKFRAME)

$button = GUICtrlCreateButton("Exit", 100, 100, 100, 25)
GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()

Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $button
Exit
EndSelect
WEnd
EndFunc ;==>_Main


Function _GUICtrlIpAddressDelete

Function Reference

_GUICtrlIpAddressDelete

Deletes the IpAddress control

#Include <GuiIPAddress.au3>
_GUICtrlIpAddressDelete ( hwnd )

Parameters

hwnd handle to a gui window

Return Value

Remarks

None

Related

_GUICtrlIpAddressCreate

Example

#include <GuiIPAddress.au3>

Opt("MustDeclareVars", 1)

_Main()

Func _Main()
Local $msg, $hgui, $button, $hIPAddress, $btn_Delete

$hgui = GUICreate("IP Address Delete Control Example", 300, 150)

$hIPAddress = _GUICtrlIpAddressCreate ($hgui, 10, 10, 125, 30, $WS_THICKFRAME)
$btn_Delete = GUICtrlCreateButton("Delete",10,100,100,25)
$button = GUICtrlCreateButton("Exit", 150, 100, 100, 25)
GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()

Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $button
Exit
Case $msg = $btn_Delete
_GUICtrlIpAddressDelete($hIPAddress)
EndSelect
WEnd
EndFunc ;==>_Main


Function _GUICtrlIpAddressGet

Function Reference

_GUICtrlIpAddressGet

Retrieves the address values for all four fields in the IP address control

#Include <GuiIPAddress.au3>
_GUICtrlIpAddressGet ( hwnd )

Parameters

hwnd handle to a gui window

Return Value

Remarks

None

Related

_GUICtrlIpAddressSet

Example

#include <GuiIPAddress.au3>

Opt("MustDeclareVars", 1)

Global $hIPAddress

_Main()

Func _Main()
Local $msg, $hgui, $clear, $getaddress, $button, $hIPAddress

$hgui = GUICreate("IP Address Control Create Example", 300, 150)

$hIPAddress = _GUICtrlIpAddressCreate ($hgui, 10, 10, 125, 30, $WS_THICKFRAME)

$clear = GUICtrlCreateButton("Clear IP", 10, 50, 80, 20)
$getaddress = GUICtrlCreateButton("Get IP", 95, 50, 80, 20)

$button = GUICtrlCreateButton("Exit", 100, 100, 100, 25)
_GUICtrlIpAddressSet ($hIPAddress, "24.168.2.128")
GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE Or $msg = $button
Exit
Case $msg = $clear
_GUICtrlIpAddressClear ($hIPAddress)
Case $msg = $getaddress
MsgBox(0, "IP Entered", _GUICtrlIpAddressGet ($hIPAddress))
EndSelect
WEnd
EndFunc ;==>_Main


Function _GUICtrlIpAddressIsBlank

Function Reference

_GUICtrlIpAddressIsBlank

Determines if all fields in the IP address control are blank

#Include <GuiIPAddress.au3>
_GUICtrlIpAddressIsBlank ( hwnd )

Parameters

hwnd handle to a gui window

Return Value

Remarks

None

Related

_GUICtrlIpAddressClear, _GUICtrlIpAddressGet, _GUICtrlIpAddressSet

Example

#include <GuiIPAddress.au3>

Opt("MustDeclareVars", 1)

_Main()

Func _Main()
Local $msg, $hgui, $clear, $getaddress, $isblank, $button, $hIPAddress

$hgui = GUICreate("IP Address Control Create Example", 300, 150)

$hIPAddress = _GUICtrlIpAddressCreate ($hgui, 10, 10, 125, 30, $WS_THICKFRAME)

$clear = GUICtrlCreateButton("Clear IP", 10, 50, 80, 20)
$getaddress = GUICtrlCreateButton("Get IP", 95, 50, 80, 20)
$isblank = GUICtrlCreateButton("Is Blank?", 180, 50, 80, 20)

$button = GUICtrlCreateButton("Exit", 100, 100, 100, 25)
_GUICtrlIpAddressSet ($hIPAddress, "24.168.2.128")
GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE Or $msg = $button
Exit
Case $msg = $clear
_GUICtrlIpAddressClear ($hIPAddress)
Case $msg = $getaddress
MsgBox(0, "IP Entered", _GUICtrlIpAddressGet ($hIPAddress))
Case $msg = $isblank
If _GUICtrlIpAddressIsBlank ($hIPAddress) Then
MsgBox(0, "Fields Check", "All IP Fields are blank")
Else
MsgBox(0, "Fields Check", "NOT All IP Fields are blank")
EndIf
EndSelect
WEnd
EndFunc ;==>_Main


Function _GUICtrlIpAddressSet

Function Reference

_GUICtrlIpAddressSet

Sets the address values for all four fields in the IP address control

#Include <GuiIPAddress.au3>
_GUICtrlIpAddressSet ( hwnd, ip )

Parameters

hwnd | handle to a gui window
ip | string containing new ip address for the control

Return Value

Remarks

None

Related

_GUICtrlIpAddressClear, _GUICtrlIpAddressGet, _GUICtrlIpAddressIsBlank

Example

#include <GuiIPAddress.au3>

Opt("MustDeclareVars", 1)

_Main()

Func _Main()
Local $msg, $hgui, $button, $hIPAddress

$hgui = GUICreate("IP Address Control Create Example", 300, 150)

$hIPAddress = _GUICtrlIpAddressCreate ($hgui, 10, 10, 125, 30, $WS_THICKFRAME)

$button = GUICtrlCreateButton("Exit", 100, 100, 100, 25)
_GUICtrlIpAddressSet ($hIPAddress, "24.168.2.128")
GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE Or $msg = $button
Exit
EndSelect
WEnd
EndFunc ;==>_Main


Function _GUICtrlIpAddressSetFocus

Function Reference

_GUICtrlIpAddressSetFocus

Sets the keyboard focus to the specified field in the IP address control.
All of the text in that field will be selected.

#Include <GuiIPAddress.au3>
_GUICtrlIpAddressSetFocus ( hwnd, field )

Parameters

hwnd | handle to a gui window
field | Zero-based field index to which the focus should be set

Return Value

Remarks

field
If this value is greater than the number of fields,
focus is set to the first blank field.
If all fields are nonblank, focus is set to the first field.

Related

_GUICtrlIpAddressClear, _GUICtrlIpAddressGet, _GUICtrlIpAddressIsBlank, _GUICtrlIpAddressSet

Example

#include <GuiIPAddress.au3>

Opt("MustDeclareVars", 1)

_Main()

Func _Main()
Local $msg, $hgui, $setfocus, $button, $hIPAddress
Local $index = 1

$hgui = GUICreate("IP Address Control Create Example", 300, 150)

$hIPAddress = _GUICtrlIpAddressCreate ($hgui, 10, 10, 125, 30, $WS_THICKFRAME)

$setfocus = GUICtrlCreateButton("Set Focus", 10, 50, 80, 20)

$button = GUICtrlCreateButton("Exit", 100, 100, 100, 25)

_GUICtrlIpAddressSet ($hIPAddress, "24.168.2.128")
GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE Or $msg = $button
Exit
Case $msg = $setfocus
_GUICtrlIpAddressSetFocus ($hIPAddress, $index)
If $index < 3 Then
$index += 1
Else
$index = 0
EndIf
EndSelect
WEnd
EndFunc ;==>_Main


Function _GUICtrlIpAddressSetFont

Function Reference

_GUICtrlIpAddressSetFont

Set the font for the control

#Include <GuiIPAddress.au3>
_GUICtrlIpAddressSetFont ( hwnd [, Name = "Arial" [, Size = 10 [, Weight = 400 [, Italic = False]]]] )

Parameters

hwnd | handle to a GUI IP Address control
Name | Optional: The Font Name of the font to use (Default: Arial)
Size | Optional: The Font Size (Default: 10)
Weight | Optional: The Font Weight (Default: 400 = normal)
Italic | Optional: Use Italic Attribute (Default: False)

Return Value

Remarks

None

Related

_GUICtrlIpAddressCreate

Example

#include <GuiIPAddress.au3>

Opt("MustDeclareVars", 1)

_Main()

Func _Main()
Local $msg, $hgui, $button, $hIPAddress, $hIPAddress2

$hgui = GUICreate("IP Address Control Set Font Example", 300, 150)

$hIPAddress = _GUICtrlIpAddressCreate ($hgui, 10, 10, 150, 30, $WS_DLGFRAME, $WS_EX_CLIENTEDGE)
$hIPAddress2 = _GUICtrlIpAddressCreate ($hgui, 10, 50, 150, 30, $WS_DLGFRAME, $WS_EX_CLIENTEDGE)

$button = GUICtrlCreateButton("Exit", 100, 120, 100, 25)

GUISetState(@SW_SHOW)

_GUICtrlIpAddressSet ($hIPAddress, "24.168.2.128")
_GUICtrlIpAddressSetFont($hIPAddress, "Times New Roman", 14, 800, True)
_GUICtrlIpAddressSet ($hIPAddress2, "24.168.2.128")
_GUICtrlIpAddressSetFont($hIPAddress2, "Arial", 12, 300)

While 1
$msg = GUIGetMsg()

Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $button
Exit
EndSelect
WEnd
EndFunc ;==>_Main


Function _GUICtrlIpAddressSetRange

Function Reference

_GUICtrlIpAddressSetRange

Sets the valid range for the specified field in the IP address control

#Include <GuiIPAddress.au3>
_GUICtrlIpAddressSetRange ( hwnd, field [, low [, high]] )

Parameters

hwnd | handle to a gui window
field | Zero-based field index to which the range will be applied
low | [optional] value that contains the lower limit of the range default (0)
high | [optional] value that contains the upper limit of the range default (255)

Return Value

Remarks

None

Related

_GUICtrlIpAddressClear, _GUICtrlIpAddressGet, _GUICtrlIpAddressIsBlank, _GUICtrlIpAddressSet

Example

#include <GuiIPAddress.au3>

Opt("MustDeclareVars", 1)

_Main()

Func _Main()
Local $msg, $hgui, $setrange, $button, $hIPAddress

$hgui = GUICreate("IP Address Control Create Example", 300, 150)

$hIPAddress = _GUICtrlIpAddressCreate ($hgui, 10, 10, 125, 30, $WS_THICKFRAME)

$setrange = GUICtrlCreateButton("Set Range", 10, 50, 80, 20)

$button = GUICtrlCreateButton("Exit", 100, 100, 100, 25)
_GUICtrlIpAddressSet ($hIPAddress, "24.168.2.128")
GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE Or $msg = $button
Exit
Case $msg = $setrange
_GUICtrlIpAddressSetRange ($hIPAddress, 0, 198, 200)
EndSelect
WEnd
EndFunc ;==>_Main


Function _GUICtrlIpAddressShowHide

Function Reference

_GUICtrlIpAddressShowHide

Shows/Hides the IP address control

#Include <GuiIPAddress.au3>
_GUICtrlIpAddressShowHide ( hwnd, state )

Parameters

hwnd | handle to a GUI IP Address control
state | @SW_SHOW/@SW_HIDE

Return Value

Remarks

None

Related

_GUICtrlIpAddressCreate, _GUICtrlIpAddressDelete

Example

#include <GuiIPAddress.au3>

Opt("MustDeclareVars", 1)

_Main()

Func _Main()
Local $msg, $hgui, $btn_show, $button, $hIPAddress, $Visible = True

$hgui = GUICreate("IP Address Control Show/Hide Example", 300, 150)

$hIPAddress = _GUICtrlIpAddressCreate ($hgui, 10, 10, 150, 30, $WS_DLGFRAME, $WS_EX_CLIENTEDGE)
_GUICtrlIpAddressSet ($hIPAddress, "24.168.2.128")

$btn_show = GUICtrlCreateButton("Show/Hide", 10, 50, 100, 25)

$button = GUICtrlCreateButton("Exit", 100, 120, 100, 25)

GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()

Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $button
Exit
Case $msg = $btn_show
If $Visible Then
_GUICtrlIpAddressShowHide ($hIPAddress, @SW_HIDE)
Else
_GUICtrlIpAddressShowHide ($hIPAddress, @SW_SHOW)
EndIf
$Visible = Not $Visible
EndSelect
WEnd
EndFunc ;==>_Main


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: GuiList Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_GUICtrlListAddDir | Add File/Folder names to the list displayed by the list box
_GUICtrlListAddItem | Add an item to the List
_GUICtrlListClear | Remove all items from the list box
_GUICtrlListCount | Get the number of items in the list box
_GUICtrlListDeleteItem | Delete an Item from the List
_GUICtrlListFindString | Return the index of matching item
_GUICtrlListGetAnchorIndex | Get the Anchor Index
_GUICtrlListGetCaretIndex | Return index of item that has the focus rectangle
_GUICtrlListGetHorizontalExtent | Retrieve from a list box the the scrollable width (pixels)
_GUICtrlListGetInfo | Retrieve the number of items per column in a specified list box.
_GUICtrlListGetItemRect | Retrieve the dimensions of the rectangle that bounds a list box item.
_GUICtrlListGetLocale | Current Locale of the listbox
_GUICtrlListGetSelCount | Get the number of items selected
_GUICtrlListGetSelItems | Get item indices of selected items
_GUICtrlListGetSelItemsText | Get the text of selected items
_GUICtrlListGetSelState | Get the selection state of item
_GUICtrlListGetText | Returns the item (string) at the specified index
_GUICtrlListGetTextLen | Alternative to StringLen
_GUICtrlListGetTopIndex | Retrieve the index of the first visible item in a list
_GUICtrlListInsertItem | Insert a string into the list
_GUICtrlListReplaceString | Replaces the text of an item at index
_GUICtrlListSelectedIndex | Return the index of selected item
_GUICtrlListSelectIndex | Select a string and scroll it into view, if necessary
_GUICtrlListSelectString | Select item using search string
_GUICtrlListSelItemRange | Select range by index in a multiple-selection list box
_GUICtrlListSelItemRangeEx | Selects items from $i_start to $i_stop
_GUICtrlListSetAnchorIndex | Set the Anchor Index
_GUICtrlListSetCaretIndex | Set the focus rectangle to the item at the specified index.
_GUICtrlListSetHorizontalExtent | Set the width, in pixels, by which a list box can be scrolled horizontally
_GUICtrlListSetLocale | Set the locale
_GUICtrlListSetSel | Select string(s) in a multiple-selection list box
_GUICtrlListSetTopIndex | Ensure that a particular item in a list box is visible
_GUICtrlListSort | Re-sorts list box if it has the $LBS_SORT style
_GUICtrlListSwapString | Swaps the text of two items at the specified indices


Function _GUICtrlListAddDir

Function Reference

_GUICtrlListAddDir

Add File/Folder names to the list displayed by the list box

#Include <GuiList.au3>
_GUICtrlListAddDir ( $h_listbox, $s_Attributes [, $s_file="" ] )

Parameters

$h_listbox | control id/control hWnd
$s_Attributes | Comma-delimited string eg "A,H" "D,A" "Drives"
$s_file | Optional for "Drives" only: What Files/Folders to get eg *.*

Return Value

zero-based index of the last name added to the list
If an error occurs, the return value is $LB_ERR.
If there is insufficient space to store the new strings, the return value is $LB_ERRSPACE

Remarks

Requirement: $s_file for all but drives attribute

$s_Attributes is an comma-delimited string
valid values are any of the following:
A,D,H,RO,RW,S,E,Drives,NB

A = ARCHIVE | Includes archived files.
D = DIRECTORY | Includes subdirectories. Subdirectory names are enclosed in square brackets ([ ]).
H = HIDDEN | Includes hidden files.
RO = READONLY | Includes read-only files.
RW = READWRITE | Includes read-write files with no additional attributes. This is the default setting.
S = SYSTEM | Includes system files.
E = EXCLUSIVE | Includes only files with the specified attributes. By default, read-write files are listed even if READWRITE is not specified.
DRIVES | All mapped drives are added to the list. Drives are listed in the form [-x-], where x is the drive letter.
NB = No Brackets |
Drives are listed in the form x:, where x is the drive letter (used with Drives attribute) |

Related

_GUICtrlListDeleteItem, _GUICtrlListClear

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt('MustDeclareVars', 1)

Dim $a_check[10], $msg, $ret, $s_attr
Dim $input, $group, $a_attr, $listbox, $button, $btn_exit

GUICreate("ListBox Add Item Demo", 400, 250, -1, -1)
GUICtrlCreateLabel("Enter files to find", 25, 15)
$input = GUICtrlCreateInput("", 125, 10, 180, 25)
$group = GUICtrlCreateGroup("Atrributes", 10, 40, -1, 200)
$a_attr = StringSplit("A,D,H,RO,RW,S,E,Drives,NB", ",")
$a_check[0] = 9
$a_check[1] = GUICtrlCreateCheckbox("Archive", 15, 55, 170, 20)
$a_check[2] = GUICtrlCreateCheckbox("Directory", 15, 75, 170, 20)
$a_check[3] = GUICtrlCreateCheckbox("Hidden", 15, 95, 170, 20)
$a_check[4] = GUICtrlCreateCheckbox("Read-Only", 15, 115, 170, 20)
$a_check[5] = GUICtrlCreateCheckbox("Read-Write", 15, 135, 95, 20)
$a_check[6] = GUICtrlCreateCheckbox("System", 15, 155, 170, 20)
$a_check[7] = GUICtrlCreateCheckbox("Exclusive", 15, 175, 170, 20)
$a_check[8] = GUICtrlCreateCheckbox("Drives", 15, 195, 170, 20)
$a_check[9] = GUICtrlCreateCheckbox("No Brackets (Drives Only)", 15, 215, 170, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group

$listbox = GUICtrlCreateList("", 240, 40, 120, 120)
$button = GUICtrlCreateButton("Get Names", 240, 160, 120, 40)
$btn_exit = GUICtrlCreateButton("Exit", 240, 205, 120, 40)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $btn_exit
ExitLoop
Case $msg = $button
$s_attr = ""
For $i = 1 To $a_check[0]
If (BitAND(GUICtrlRead($a_check[$i]), $GUI_CHECKED)) Then
If (StringLen($s_attr) > 0) Then
$s_attr &= "," & $a_attr[$i]
Else
$s_attr = $a_attr[$i]
EndIf
EndIf
Next
_GUICtrlListClear ($listbox)
$ret = _GUICtrlListAddDir ($listbox, $s_attr, GUICtrlRead($input))
If ($ret < 0) Then
If ($ret == $LB_ERRATTRIBUTE) Then
MsgBox(16, "Error", "Invalid Attribute sent to _GUICtrlListAddDir")
ElseIf ($ret == $LB_ERRSPACE) Then
MsgBox(16, "Error", "insufficient space to store the new strings from calling _GUICtrlListAddDir")
ElseIf ($ret == $LB_ERRREQUIRED) Then
MsgBox(16, "Error", "Argument required for file search in call to _GUICtrlListAddDir")
ElseIf ($ret == $LB_ERR) Then
MsgBox(16, "Error", "Unknown error from _GUICtrlListAddDir" & @CRLF & "Possibly no files/folders found")
EndIf
EndIf
EndSelect
WEnd


Function _GUICtrlListAddItem

Function Reference

_GUICtrlListAddItem

Add an item to the List

#Include <GuiList.au3>
_GUICtrlListAddItem ( $h_listbox, $s_text )

Parameters

$h_listbox | control id/control hWnd
$s_text | String to add

Return Value

The return value is the zero-based index of the string in the list box.
If an error occurs, the return value is $LB_ERR.
If there is insufficient space to store the new string, the return value is $LB_ERRSPACE.

Remarks

If the list box does not have the $LBS_SORT style, the string is added to the
end of the list. Otherwise, the string is inserted into the list and the list
is sorted.

Related

_GUICtrlListDeleteItem, _GUICtrlListInsertItem, _GUICtrlListReplaceString, _GUICtrlListSwapString

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $ret
Dim $input, $listbox, $button

GUICreate("ListBox Add Item Demo", 400, 250, -1, -1)
GUICtrlCreateLabel("Enter item to add", 25, 15)
$input = GUICtrlCreateInput("", 125, 10, 180, 25)

$listbox = GUICtrlCreateList("", 125, 40, 180, 120)
$button = GUICtrlCreateButton("Add to List", 150, 160, 120, 40)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
If (StringLen(GUICtrlRead($input)) > 0) Then
$ret = _GUICtrlListAddItem ($listbox, GUICtrlRead($input))
If ($ret < 0) Then
If ($ret == $LB_ERRSPACE) Then
MsgBox(16, "Error", "insufficient space to store the new strings from calling _GUICtrlListAddItem")
ElseIf ($ret == $LB_ERR) Then
MsgBox(16, "Error", "Unknown error from _GUICtrlListAddItem")
EndIf
EndIf
EndIf
EndSelect
WEnd


Function _GUICtrlListClear

Function Reference

_GUICtrlListClear

Remove all items from the list box

#Include <GuiList.au3>
_GUICtrlListClear ( $h_listbox )

Parameters

$h_listbox control id/control hWnd

Return Value

None.

Remarks

None.

Related

_GUICtrlListDeleteItem, _GUICtrlListAddItem, _GUICtrlListInsertItem

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $ret
Dim $listbox, $button

GUICreate("ListBox Clear All Items Demo", 400, 250, -1, -1)

$listbox = GUICtrlCreateList("", 125, 40, 180, 120)
GUICtrlSetData($listbox, "test1|test2|test3|")
$button = GUICtrlCreateButton("Clear All", 150, 160, 120, 40)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
_GUICtrlListClear ($listbox)
EndSelect
WEnd


Function _GUICtrlListCount

Function Reference

_GUICtrlListCount

Get the number of items in the list box

#Include <GuiList.au3>
_GUICtrlListCount ( $h_listbox )

Parameters

$h_listbox control id/control hWnd

Return Value

The return value is the number of items in the list box
or $LB_ERR if an error occurs

Remarks

None.

Related

_GUICtrlListGetSelCount, _GUICtrlListGetSelItems, _GUICtrlListGetSelItemsText

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $ret
Dim $listbox, $button, $label

GUICreate("ListBox Count Item(s) Demo", 400, 250, -1, -1)

$listbox = GUICtrlCreateList("", 125, 40, 180, 120)
GUICtrlSetData($listbox, "test1|test2|test3|")
$button = GUICtrlCreateButton("Count Items", 150, 160, 120, 40)
$label = GUICtrlCreateLabel("# of Items", 150, 210, 120)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$ret = _GUICtrlListCount ($listbox)
If ($ret == $LB_ERR) Then
MsgBox(16, "Error", "Unknown error from _GUICtrlListCount")
Else
GUICtrlSetData($label, "# of Items: " & $ret)
EndIf
EndSelect
WEnd


Function _GUICtrlListDeleteItem

Function Reference

_GUICtrlListDeleteItem

Delete an Item from the List

#Include <GuiList.au3>
_GUICtrlListDeleteItem ( $h_listbox, $i_index )

Parameters

$h_listbox | control id/control hWnd
$i_index | Zero-based index of item to delete

Return Value

The return value is a count of the strings remaining in the list.
The return value is $LB_ERR if the $i_index parameter specifies an
index greater than the number of items in the list.

Remarks

None.

Related

_GUICtrlListAddItem, _GUICtrlListInsertItem, _GUICtrlListClear

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $ret
Dim $listbox, $button

GUICreate("ListBox Delete Item Demo", 400, 250, -1, -1)

$listbox = GUICtrlCreateList("", 125, 40, 180, 120)
GUICtrlSetData($listbox, "test1|test2|test3|")
$button = GUICtrlCreateButton("Delete item #2", 150, 160, 120, 40)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$ret = _GUICtrlListDeleteItem ($listbox, 1)
If ($ret == $LB_ERR) Then
MsgBox(16, "Error", "Unknown error from _GUICtrlListDeleteItem")
EndIf
EndSelect
WEnd


Function _GUICtrlListFindString

Function Reference

_GUICtrlListFindString

Return the index of matching item

#Include <GuiList.au3>
_GUICtrlListFindString ( $h_listbox, $s_search [, $i_exact=0 ] )

Parameters

$h_listbox | control id/control hWnd
$s_search | string to search for
$i_exact | Optional: exact match or not

Return Value

The return value is the index of the matching item,
or $LB_ERR if the search was unsuccessful.

Remarks

Finds the first string in a list box that begins with the specified string.
If exact is specified find the first list box string that exactly matches
the specified string, except that the search is not case sensitive

Related

None.

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $ret
Dim $input, $listbox, $button, $label, $button2

GUICreate("ListBox Find String Demo", 400, 250, -1, -1)
GUICtrlCreateLabel("Enter item to add", 25, 15)
$input = GUICtrlCreateInput("", 125, 10, 180, 25)

$listbox = GUICtrlCreateList("", 125, 40, 180, 120)
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|")
$button = GUICtrlCreateButton("Begins with", 85, 160, 120, 40)
$button2 = GUICtrlCreateButton("Exact Match", 215, 160, 120, 40)
$label = GUICtrlCreateLabel("Item #", 150, 210, 120)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
If (StringLen(GUICtrlRead($input)) > 0) Then
$ret = _GUICtrlListFindString ($listbox, GUICtrlRead($input))
If ($ret == $LB_ERR) Then
MsgBox(16, "Error", "Unknown error from _GUICtrlListFindString")
Else
GUICtrlSetData($label, "Item #: " & $ret)
EndIf
EndIf
Case $msg = $button2
If (StringLen(GUICtrlRead($input)) > 0) Then
$ret = _GUICtrlListFindString($listbox, GUICtrlRead($input), 1)
If ($ret == $LB_ERR) Then
MsgBox(16, "Error", "Unknown error from _GUICtrlListFindString")
Else
GUICtrlSetData($label, "Item #: " & $ret)
EndIf
EndIf
EndSelect
WEnd


Function _GUICtrlListGetAnchorIndex

Function Reference

_GUICtrlListGetAnchorIndex

Get the Anchor Index

#Include <GuiList.au3>
_GUICtrlListGetAnchorIndex ( $h_listbox )

Parameters

$h_listbox control id/control hWnd

Return Value

The return value is the index of the anchor item.
If an error occurs, the return value is $LB_ERR

Remarks

DOES NOT WORK WITH SINGLE-SELECTION LIST BOXES
This might not always be the first selected item--especially
if you select every other item via Ctrl+Click...

Related

_GUICtrlListSetAnchorIndex

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $ret, $listbox, $button, $label

GUICreate("ListBox Get Anchor Index Demo", 400, 250, -1, -1)

$listbox = GUICtrlCreateList("", 125, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|test2|test3|test4|test5|test6|test7|test8|test9|test10")
$button = GUICtrlCreateButton("Get Anchor", 150, 160, 120, 40)
$label = GUICtrlCreateLabel("Anchor Index:", 150, 210, 120)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$ret = _GUICtrlListGetAnchorIndex ($listbox)
If ($ret == $LB_ERR) Then
MsgBox(16, "Error", "Unknown error from _GUICtrlListGetAnchorIndex")
Else
GUICtrlSetData($label, "Anchor Index: " & $ret)
EndIf
EndSelect
WEnd


Function _GUICtrlListGetCaretIndex

Function Reference

_GUICtrlListGetCaretIndex

Return index of item that has the focus rectangle

#Include <GuiList.au3>
_GUICtrlListGetCaretIndex ( $h_listbox )

Parameters

$h_listbox control id/control hWnd

Return Value

The return value is the zero-based index of the selected list box item.
If nothing is selected $LB_ERR can be returned.

Remarks

To determine the index of the item that has the focus rectangle in a
multiple-selection list box. The item may or may not be selected

Related

_GUICtrlListGetTopIndex, _GUICtrlListGetAnchorIndex

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $ret
Dim $listbox, $label, $button

GUICreate("ListBox Get Caret Index Demo", 400, 250, -1, -1)

$listbox = GUICtrlCreateList("", 125, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|")
$button = GUICtrlCreateButton("Get Index", 150, 160, 120, 40)
$label = GUICtrlCreateLabel("Item #", 150, 210, 120)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$ret = _GUICtrlListGetCaretIndex ($listbox)
GUICtrlSetData($label, "Item : " & $ret)
EndSelect
WEnd


Function _GUICtrlListGetHorizontalExtent

Function Reference

_GUICtrlListGetHorizontalExtent

Retrieve from a list box the the scrollable width (pixels)

#Include <GuiList.au3>
_GUICtrlListGetHorizontalExtent ( $h_listbox )

Parameters

$h_listbox control id/control hWnd

Return Value

The return value is the scrollable width, in pixels, of the list box.

Remarks

The list box must have been defined with the $WS_HSCROLL style.

Related

_GUICtrlListSetHorizontalExtent

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $listbox, $label

GUICreate("ListBox Get Horizontal Extent", 400, 250, -1, -1)

$listbox = GUICtrlCreateList("", 125, 40, 100, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_DISABLENOSCROLL, $WS_HSCROLL))
_GUICtrlListSetHorizontalExtent ($listbox, 120)
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|test2|test3|test4|test5|test6|test7|test8|")
$label = GUICtrlCreateLabel("HorizontalExtent: " & _GUICtrlListGetHorizontalExtent ($listbox), 150, 210, 120)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd


Function _GUICtrlListGetInfo

Function Reference

_GUICtrlListGetInfo

Retrieve the number of items per column in a specified list box.

#Include <GuiList.au3>
_GUICtrlListGetInfo ( $h_listbox )

Parameters

$h_listbox control id/control hWnd

Return Value

The return value is the number of items per column.

Remarks

Minimum operating systems Windows XP

Related

None.

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $listbox, $label

GUICreate("ListBox Get Info", 400, 250, -1, -1)

$listbox = GUICtrlCreateList("", 125, 40, 100, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY))
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|test2|test3|test4|test5|test6|test7|test8|")
$label = GUICtrlCreateLabel("Info: " & _GUICtrlListGetInfo ($listbox), 150, 210, 120)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd


Function _GUICtrlListGetItemRect

Function Reference

_GUICtrlListGetItemRect

Retrieve the dimensions of the rectangle that bounds a list box item.

#Include <GuiList.au3>
_GUICtrlListGetItemRect ( $h_listbox, $i_index )

Parameters

$h_listbox | control id/control hWnd
$i_index | Specifies the zero-based index of the item.

Return Value

Array containing the RECT, first element ($array[0]) contains the number of elements
If an error occurs, the return value is $LB_ERR.

Remarks

$array[1] - left
$array[2] - top
$array[3] - right
$array[4] - bottom

Related

None.

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

opt('MustDeclareVars', 1)

Dim $listbox, $s_rect, $label_rect, $Btn_GETRECT, $Btn_Exit, $msg

GUICreate("ListBox Get Item RECT", 400, 250, -1, -1)

$listbox = GUICtrlCreateList("", 50, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|")

$s_rect = "Left:" & @LF & "Top:" & @LF & "Right:" & @LF & "Bottom:"
$label_rect = GUICtrlCreateLabel($s_rect, 270, 40, 100, 55, $SS_SUNKEN)

$Btn_GETRECT = GUICtrlCreateButton("Get Item Rect", 270, 120, 90, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 150, 180, 90, 30)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_GETRECT
Local $rect_array = _GUICtrlListGetItemRect($listbox, 3)
If (IsArray($rect_array)) Then
$s_rect = "Left:" & $rect_array[1] & @LF & "Top:" & $rect_array[2] & @LF & "Right:" & $rect_array[3] & @LF & "Bottom:" & $rect_array[4]
GUICtrlSetData($label_rect, $s_rect)
EndIf
EndSelect
WEnd


Function _GUICtrlListGetLocale

Function Reference

_GUICtrlListGetLocale

Current Locale of the listbox

#Include <GuiList.au3>
_GUICtrlListGetLocale ( $h_listbox )

Parameters

$h_listbox control id/control hWnd

Return Value

Returns the current Local of the listbox
same as @OSLang unless changed

Remarks

"0409" for U.S. English

Related

_GUICtrlListSetLocale

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $ret, $listbox, $button

GUICreate("ListBox Get Locale Demo", 400, 250, -1, -1)
$listbox = GUICtrlCreateList("", 125, 40, 180, 120)
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|test2|test3|test4|test5|test6|test7|test8|test9|test10")
$button = GUICtrlCreateButton('Get Locale', 150, 160, 120, 40)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$ret = _GUICtrlListGetLocale ($listbox)
If ($ret == $LB_ERR) Then
MsgBox(16, "Error", "Unknown error from _GUICtrlListGetLocale")
Else
MsgBox(0, "Locale", $ret)
EndIf
EndSelect
WEnd


Function _GUICtrlListGetSelCount

Function Reference

_GUICtrlListGetSelCount

Get the number of items selected

#Include <GuiList.au3>
_GUICtrlListGetSelCount ( $h_listbox )

Parameters

$h_listbox control id/control hWnd

Return Value

The return value is the count of selected items in the list box.
If the list box is a single-selection list box, the return value is $LB_ERR.

Remarks

Retrieve the total number of selected items in a multiple-selection list box.
Number of selected items (for a control with multi-select style)

Related

_GUICtrlListGetSelItems, _GUICtrlListGetSelItemsText, _GUICtrlListSetSel

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $ret
Dim $listbox, $button, $label

GUICreate("ListBox Selected Count Demo", 400, 250, -1, -1)

$listbox = GUICtrlCreateList("", 125, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|")
$button = GUICtrlCreateButton("Get Sel Count", 150, 160, 120, 40)
$label = GUICtrlCreateLabel("# Selected: ", 150, 210, 120)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$ret = _GUICtrlListGetSelCount ($listbox)
If ($ret == $LB_ERR) Then
MsgBox(16, "Error", "Unknown error from _GUICtrlListGetSelCount")
Else
GUICtrlSetData($label, "# Selected: " & $ret)
EndIf
EndSelect
WEnd


Function _GUICtrlListGetSelItems

Function Reference

_GUICtrlListGetSelItems

Get item indices of selected items

#Include <GuiList.au3>
_GUICtrlListGetSelItems ( $h_listbox )

Parameters

$h_listbox control id/control hWnd

Return Value

Array of selected items indices, first element ($array[0]) contains the number indices returned
If the list box is a single-selection list box, the return value is $LB_ERR.
If no items are selected, the return value is $LB_ERR.

Remarks

None.

Related

_GUICtrlListSelectedIndex, _GUICtrlListGetSelState, _GUICtrlListGetSelCount, _GUICtrlListGetSelItemsText, _GUICtrlListGetSelItems, _GUICtrlListSelItemRange, _GUICtrlListSelItemRangeEx

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $ret, $listbox, $button, $i

GUICreate("ListBox Selected Items Indices Demo", 400, 250, -1, -1)
$listbox = GUICtrlCreateList("", 125, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|")
$button = GUICtrlCreateButton("Get Selected", 150, 160, 120, 40)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$ret = _GUICtrlListGetSelItems ($listbox)
If (Not IsArray($ret)) Then
MsgBox(16, "Error", "Unknown error from _GUICtrlListGetSelItems")
Else
For $i = 1 To $ret[0]
MsgBox(0, "Selected", $ret[$i])
Next
EndIf
EndSelect
WEnd


Function _GUICtrlListGetSelItemsText

Function Reference

_GUICtrlListGetSelItemsText

Get the text of selected items

#Include <GuiList.au3>
_GUICtrlListGetSelItemsText ( $h_listbox )

Parameters

$h_listbox control id/control hWnd

Return Value

Array of selected items text, first element ($array[0]) contains the number items returned
If the list box is a single-selection list box, the return value is $LB_ERR.
If no items are selected, the return value is $LB_ERR.

Remarks

None.

Related

_GUICtrlListSelectedIndex, _GUICtrlListGetSelState, _GUICtrlListGetSelCount, _GUICtrlListGetSelItemsText

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $ret
Dim $listbox, $button, $label, $i

GUICreate("ListBox Selected Items Text Demo", 400, 250, -1, -1)

$listbox = GUICtrlCreateList("", 125, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|")
$button = GUICtrlCreateButton("Get Selected", 150, 160, 120, 40)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$ret = _GUICtrlListGetSelItemsText ($listbox)
If (Not IsArray($ret)) Then
MsgBox(16, "Error", "Unknown error from _GUICtrlListGetSelItemsText")
Else
For $i = 1 To $ret[0]
MsgBox(0, "Selected", $ret[$i])
Next
EndIf
EndSelect
WEnd


Function _GUICtrlListGetSelState

Function Reference

_GUICtrlListGetSelState

Get the selection state of item

#Include <GuiList.au3>
_GUICtrlListGetSelState ( $h_listbox, $i_index )

Parameters

$h_listbox | control id/control hWnd
$i_index | Specifies the zero-based index of the item

Return Value

If an item is selected, the return value is greater than zero
otherwise, it is zero. If an error occurs, the return value is $LB_ERR.

Remarks

None.

Related

_GUICtrlListSelectedIndex, _GUICtrlListGetSelCount, _GUICtrlListGetSelItems, _GUICtrlListGetSelItemsText

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $ret
Dim $listbox, $button, $label

GUICreate("ListBox Selected State Demo", 400, 250, -1, -1)

$listbox = GUICtrlCreateList("", 125, 40, 180, 120)
GUICtrlSetData($listbox, "test1|test2|test3|")
$button = GUICtrlCreateButton("Get Index 2 State", 150, 160, 120, 40)
$label = GUICtrlCreateLabel("State: ", 150, 210, 120)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$ret = _GUICtrlListGetSelState ($listbox, 2)
If ($ret == $LB_ERR) Then
MsgBox(16, "Error", "Unknown error from _GUICtrlListGetSelState")
Else
GUICtrlSetData($label, "State: " & $ret)
EndIf
EndSelect
WEnd


Function _GUICtrlListGetText

Function Reference

_GUICtrlListGetText

Returns the item (string) at the specified index

#Include <GuiList.au3>
_GUICtrlListGetText ( $h_listbox, $i_index )

Parameters

$h_listbox | control id/control hWnd
$i_index | Specifies the zero-based index of the string to retrieve

Return Value

The return value is the item string
If $i_index does not specify a valid index, the return value is $LB_ERR.

Remarks

None.

Related

_GUICtrlListGetSelItemsText, _GUICtrlListGetTextLen

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $ret
Dim $listbox, $label

GUICreate("ListBox Get Text Demo", 400, 250, -1, -1)

$listbox = GUICtrlCreateList("", 125, 40, 180, 120)
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|")
$label = GUICtrlCreateLabel("Item #", 150, 210, 120)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $listbox
$ret = _GUICtrlListGetText ($listbox, _GUICtrlListSelectedIndex ($listbox))
If ($ret == $LB_ERR) Then
MsgBox(16, "Error", "Unknown error from _GUICtrlListGetText")
Else
GUICtrlSetData($label, "Item : " & $ret)
EndIf
EndSelect
WEnd


Function _GUICtrlListGetTextLen

Function Reference

_GUICtrlListGetTextLen

Alternative to StringLen

#Include <GuiList.au3>
_GUICtrlListGetTextLen ( $h_listbox, $i_index )

Parameters

$h_listbox | control id/control hWnd
$i_index | Zero-based index of item

Return Value

The return value is the length of the string
If the $i_index parameter does not specify a valid index, the return value is $LB_ERR

Remarks

None.

Related

None.

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $ret, $listbox, $button

GUICreate("ListBox Text Len Demo", 400, 250, -1, -1)
GUICtrlCreateLabel("Select from list", 125, 10)
$listbox = GUICtrlCreateList("", 125, 40, 180, 120)
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|test2|test3|test4|test5|test6|test7|test8|test9|test10")
$button = GUICtrlCreateButton('Exit', 150, 160, 120, 40)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $button
ExitLoop
Case $msg = $listbox
$ret = _GUICtrlListGetTextLen ($listbox, _GUICtrlListSelectedIndex ($listbox))
If ($ret == $LB_ERR) Then
MsgBox(16, "Error", "Unknown error from _GUICtrlListGetTextLen")
Else
MsgBox(0, "Text", "Length: " & $ret)
EndIf
EndSelect
WEnd


Function _GUICtrlListGetTopIndex

Function Reference

_GUICtrlListGetTopIndex

Retrieve the index of the first visible item in a list

#Include <GuiList.au3>
_GUICtrlListGetTopIndex ( $h_listbox )

Parameters

$h_listbox control id/control hWnd

Return Value

The return value is the index of the first visible item in the list box.
If the list is empty then $LB_ERR is returned.

Remarks

Initially the item with index 0 is at the top of the list box, but if
the list box contents have been scrolled another item may be at the top.
Returns index of the first visible item in the list box
useful since contents for a long list will scroll

Related

_GUICtrlListSetTopIndex

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $ret
Dim $listbox, $button, $label, $i

GUICreate("ListBox Get Top Index Demo", 400, 250, -1, -1)

$listbox = GUICtrlCreateList("", 125, 40, 180, 120)
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|test2|test3|test4|test5|test6|test7|test8|")
$button = GUICtrlCreateButton("Get Top Index", 150, 160, 120, 40)
$label = GUICtrlCreateLabel("Top Index:", 150, 210, 120)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$ret = _GUICtrlListGetTopIndex ($listbox)
If ($ret == $LB_ERR) Then
MsgBox(16, "Error", "Unknown error from _GUICtrlListGetTopIndex")
Else
GUICtrlSetData($label, "Top Index: " & $ret)
EndIf
EndSelect
WEnd


Function _GUICtrlListInsertItem

Function Reference

_GUICtrlListInsertItem

Insert a string into the list

#Include <GuiList.au3>
_GUICtrlListInsertItem ( $h_listbox, $s_text [, $i_index=-1 ] )

Parameters

$h_listbox | control id/control hWnd
$s_text | String to insert
$i_index | Optional: Zero-based index to insert at

Return Value

The return value is the index of the position at which the string was inserted.
If an error occurs, the return value is $LB_ERR. If there is insufficient space
to store the new string, the return value is $LB_ERRSPACE.

Remarks

If this parameter is –1, the string is added to the end of the list.
Unlike the _GUICtrlListAddItem, this function does not cause a list
with the $LBS_SORT style to be sorted.

Related

_GUICtrlListAddItem

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $ret
Dim $input, $listbox, $button, $label, $button2

GUICreate("ListBox Insert Item Demo", 400, 250, -1, -1)
GUICtrlCreateLabel("Enter item to add", 25, 15)
$input = GUICtrlCreateInput("", 125, 10, 180, 25)

$listbox = GUICtrlCreateList("", 125, 40, 180, 120)
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|")
$button = GUICtrlCreateButton("Insert", 85, 160, 120, 40)
$button2 = GUICtrlCreateButton("Append", 215, 160, 120, 40)
$label = GUICtrlCreateLabel("Item #", 150, 210, 120)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
If (StringLen(GUICtrlRead($input)) > 0) Then
$ret = _GUICtrlListInsertItem ($listbox, GUICtrlRead($input), 2)
If ($ret < 0) Then
MsgBox(16, "Error", "Error (" & $ret & ") from _GUICtrlListInsertItem")
Else
GUICtrlSetData($label, "Item #: " & $ret)
EndIf
EndIf
Case $msg = $button2
If (StringLen(GUICtrlRead($input)) > 0) Then
$ret = _GUICtrlListInsertItem ($listbox, GUICtrlRead($input))
If ($ret < 0) Then
MsgBox(16, "Error", "Error (" & $ret & ") from _GUICtrlListInsertItem")
Else
GUICtrlSetData($label, "Item #: " & $ret)
EndIf
EndIf
EndSelect
WEnd


Function _GUICtrlListReplaceString

Function Reference

_GUICtrlListReplaceString

Replaces the text of an item at index

#Include <GuiList.au3>
_GUICtrlListReplaceString ( $h_listbox, $i_index, $s_newString )

Parameters

$h_listbox | control id/control hWnd
$i_index | Zero-based index of the item to replace
$s_newString | String to replace old string

Return Value

If an error occurs, the return value is $LB_ERR

Remarks

None.

Related

None.

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $ret, $listbox, $button

GUICreate("ListBox Replace String Demo", 400, 250, -1, -1)

$listbox = GUICtrlCreateList("", 125, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|test2|test3|test4|test5|test6|test7|test8|test9|test10")
$button = GUICtrlCreateButton('Set Item 3 to "gone"', 150, 160, 120, 40)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$ret = _GUICtrlListReplaceString ($listbox, 3, "gone")
If ($ret == $LB_ERR) Then
MsgBox(16, "Error", "Unknown error from _GUICtrlListReplaceString")
EndIf
EndSelect
WEnd


Function _GUICtrlListSelectedIndex

Function Reference

_GUICtrlListSelectedIndex

Return the index of selected item

#Include <GuiList.au3>
_GUICtrlListSelectedIndex ( $h_listbox )

Parameters

$h_listbox control id/control hWnd

Return Value

In a single-selection list box, the return value is the zero-based
index of the currently selected item. If there is no selection,
the return value is $LB_ERR

Remarks

Do "NOT" use this with a multiple-selection list box.

Related

_GUICtrlListGetSelCount, _GUICtrlListGetSelItems, _GUICtrlListGetSelItemsText

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $ret
Dim $listbox, $label

GUICreate("ListBox Current Selection Demo", 400, 250, -1, -1)

$listbox = GUICtrlCreateList("", 125, 40, 180, 120)
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|")
$label = GUICtrlCreateLabel("Item #", 150, 210, 120)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $listbox
$ret = _GUICtrlListSelectedIndex ($listbox)
If ($ret == $LB_ERR) Then
MsgBox(16, "Error", "Unknown error from _GUICtrlListSelectedIndex")
Else
GUICtrlSetData($label, "Item #: " & $ret)
EndIf
EndSelect
WEnd


Function _GUICtrlListSelectIndex

Function Reference

_GUICtrlListSelectIndex

Select a string and scroll it into view, if necessary

#Include <GuiList.au3>
_GUICtrlListSelectIndex ( $h_listbox, $i_index )

Parameters

$h_listbox | controlID/control hWnd
$i_index | Specifies the zero-based index of the list box item

Return Value

If an error occurs, the return value is $LB_ERR.
If the $i_index parameter is –1, the return value is $LB_ERR even though no error occurred.

Remarks

Use this message only with single-selection list boxes.
You cannot use it to set or remove a selection in a multiple-selection list box.

Related

_GUICtrlListSetSel, _GUICtrlListSelectString, _GUICtrlListGetSelState, _GUICtrlListGetSelCount, _GUICtrlListGetSelItems

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

opt('MustDeclareVars', 1)

Dim $msg, $ret
Dim $listbox, $button, $button2

GUICreate("ListBox Set Selection(s) Demo", 400, 250, -1, -1)

$listbox = GUICtrlCreateList("", 125, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY))
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|test2|test3|test4|test5|test6|test7|test8|test9|test10")
$button = GUICtrlCreateButton("Set index 3", 160, 160, 120, 40)
$button2 = GUICtrlCreateButton("Set index 12", 160, 210, 120, 40)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$ret = _GUICtrlListSelectIndex ($listbox, 3)
If ($ret == $LB_ERR) Then
MsgBox(16, "Error", "Unknown error from _GUICtrlListSelectIndex")
EndIf
Case $msg = $button2
$ret = _GUICtrlListSelectIndex ($listbox, 12)
If ($ret == $LB_ERR) Then
MsgBox(16, "Error", "Unknown error from _GUICtrlListSelectIndex")
EndIf
EndSelect
WEnd


Function _GUICtrlListSelectString

Function Reference

_GUICtrlListSelectString

Select item using search string

#Include <GuiList.au3>
_GUICtrlListSelectString ( $h_listbox, $s_search [, $i_index=-1 ] )

Parameters

$h_listbox | control id/control hWnd
$s_text | String to select
$i_index | Optional: Zero-based index of the item before the first item to be searched

Return Value

If the search is successful, the return value is the index of the selected item.
If the search is unsuccessful, the return value is $LB_ERR and the current selection is not changed.

Remarks

If $i_index is –1, the entire list box is searched from the beginning

Related

_GUICtrlListFindString

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $ret
Dim $input, $listbox, $button, $label, $button2

GUICreate("ListBox Select String Demo", 400, 250, -1, -1)
GUICtrlCreateLabel("Enter String to Select", 25, 15)
$input = GUICtrlCreateInput("", 125, 10, 180, 25)

$listbox = GUICtrlCreateList("", 125, 40, 180, 120)
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|")
$button = GUICtrlCreateButton("Start from index 3", 85, 160, 120, 40)
$button2 = GUICtrlCreateButton("Start from index 0", 215, 160, 120, 40)
$label = GUICtrlCreateLabel("Item #", 150, 210, 120)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
If (StringLen(GUICtrlRead($input)) > 0) Then
$ret = _GUICtrlListSelectString ($listbox, GUICtrlRead($input), 3)
If ($ret == $LB_ERR) Then
MsgBox(16, "Error", "Not Found")
Else
GUICtrlSetData($label, "Item #: " & $ret)
EndIf
EndIf
Case $msg = $button2
If (StringLen(GUICtrlRead($input)) > 0) Then
$ret = _GUICtrlListSelectString ($listbox, GUICtrlRead($input))
If ($ret == $LB_ERR) Then
MsgBox(16, "Error", "Not Found")
Else
GUICtrlSetData($label, "Item #: " & $ret)
EndIf
EndIf
EndSelect
WEnd


Function _GUICtrlListSelItemRange

Function Reference

_GUICtrlListSelItemRange

Select range by index in a multiple-selection list box

#Include <GuiList.au3>
_GUICtrlListSelItemRange ( $h_listbox, $i_flag, $i_start, $i_stop )

Parameters

$h_listbox | control id/control hWnd
$i_flag | Set/Remove select
$i_start | Zero-based index of the first item to select
$i_stop | Zero-based index of the last item to select

Return Value

If an error occurs, the return value is $LB_ERR

Remarks

DOES NOT WORK WITH SINGLE-SELECTION LIST BOXES
Select items from $i_start to $stop indices (inclusive)
Can select a range only within the first 65,536 items
$i_flag == 1 selects
$i_flag == 0 removes select

Related

_GUICtrlListSelItemRangeEx

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt('MustDeclareVars',1)

Dim $msg, $ret,$listbox,$button,$i_sel=1

GUICreate("ListBox Set Item Range Demo",400,250,-1,-1)

$listbox = GUICtrlCreateList("",125,40,180,120,BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY,$LBS_MULTIPLESEL))
GUICtrlSetData($listbox,"test1|more testing|even more testing|demo|test2|test3|test4|test5|test6|test7|test8|test9|test10")
$button = GUICtrlCreateButton("Set/UnSet Items 1 - 5",150,160,120,40)

GUISetState ()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$ret = _GUICtrlListSelItemRange($listbox,$i_sel,1,5)
If($ret == $LB_ERR) Then
MsgBox(16,"Error","Unknown error from _GUICtrlListSelItemRange")
EndIf
$i_sel = Not $i_sel
EndSelect
Wend


Function _GUICtrlListSelItemRangeEx

Function Reference

_GUICtrlListSelItemRangeEx

Selects items from $i_start to $i_stop

#Include <GuiList.au3>
_GUICtrlListSelItemRangeEx ( $h_listbox, $i_start, $i_stop )

Parameters

$h_listbox | control id/control hWnd
$i_start | Zero-based index of the first item to select
$i_stop | Zero-based index of the last item to select

Return Value

If an error occurs, the return value is $LB_ERR

Remarks

DOES NOT WORK WITH SINGLE-SELECTION LIST BOXES
If $i_start > $i_stop Then items are un-selected

Related

_GUICtrlListSelItemRange

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt('MustDeclareVars',1)

Dim $msg, $ret,$listbox,$button,$button2

GUICreate("ListBox Set Item RangeEx Demo",400,250,-1,-1)

$listbox = GUICtrlCreateList("",125,40,180,120,BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY,$LBS_MULTIPLESEL))
GUICtrlSetData($listbox,"test1|more testing|even more testing|demo|test2|test3|test4|test5|test6|test7|test8|test9|test10")
$button = GUICtrlCreateButton("Set Items 1 - 5",85,160,120,40)
$button2 = GUICtrlCreateButton("UnSet Items 1 - 5",220,160,120,40)

GUISetState ()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$ret = _GUICtrlListSelItemRangeEx($listbox,1,5)
If($ret == $LB_ERR) Then
MsgBox(16,"Error","Unknown error from _GUICtrlListSelItemRangeEx")
EndIf
Case $msg = $button2
$ret = _GUICtrlListSelItemRangeEx($listbox,5,1)
If($ret == $LB_ERR) Then
MsgBox(16,"Error","Unknown error from _GUICtrlListSelItemRangeEx")
EndIf
EndSelect
Wend


Function _GUICtrlListSetAnchorIndex

Function Reference

_GUICtrlListSetAnchorIndex

Set the Anchor Index

#Include <GuiList.au3>
_GUICtrlListSetAnchorIndex ( $h_listbox, $i_index )

Parameters

$h_listbox | control id/control hWnd
$i_index | Specifies the index of the new anchor item.

Return Value

If the message succeeds, the return value is zero.
If the message fails, the return value is $LB_ERR.

Remarks

DOES NOT WORK WITH SINGLE-SELECTION LIST BOXES

Related

_GUICtrlListGetAnchorIndex

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $ret, $listbox, $button, $label

GUICreate("ListBox Set Anchor Index Demo", 400, 250, -1, -1)

$listbox = GUICtrlCreateList("", 125, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|test2|test3|test4|test5|test6|test7|test8|test9|test10")
$button = GUICtrlCreateButton("Set Anchor", 150, 160, 120, 40)
$label = GUICtrlCreateLabel("Anchor Index:", 150, 210, 120)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$ret = _GUICtrlListSetAnchorIndex ($listbox, 5)
If ($ret == $LB_ERR) Then
MsgBox(16, "Error", "Unknown error from _GUICtrlListGetAnchorIndex")
Else
$ret = _GUICtrlListGetAnchorIndex ($listbox)
If ($ret == $LB_ERR) Then
MsgBox(16, "Error", "Unknown error from _GUICtrlListGetAnchorIndex")
Else
GUICtrlSetData($label, "Anchor Index: " & $ret)
EndIf
EndIf
EndSelect
WEnd


Function _GUICtrlListSetCaretIndex

Function Reference

_GUICtrlListSetCaretIndex

Set the focus rectangle to the item at the specified index.

#Include <GuiList.au3>
_GUICtrlListSetCaretIndex ( $h_listbox, $i_index [, $i_bool=1 ] )

Parameters

$h_listbox | control id/control hWnd
$i_index | Specifies the zero-based index of the list box item that is to receive the focus rectangle.
$i_bool | Optional: If this value is FALSE, the item is scrolled until it is fully visible. If it is TRUE, the item is scrolled until it is at least partially visible.

Return Value

If an error occurs, the return value is $LB_ERR.

Remarks

DOES NOT WORK WITH SINGLE-SELECTION LIST BOXES

Related

_GUICtrlListGetTopIndex, _GUICtrlListGetAnchorIndex

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $ret
Dim $listbox, $label, $button

GUICreate("ListBox Set Caret Index Demo", 400, 250, -1, -1)

$listbox = GUICtrlCreateList("", 125, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL))
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|")
$button = GUICtrlCreateButton("Set Index", 150, 160, 120, 40)
$label = GUICtrlCreateLabel("Item #", 150, 210, 120)
$ret = _GUICtrlListGetCaretIndex ($listbox)
GUICtrlSetData($label, "Item : " & $ret)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$ret = _GUICtrlListSetCaretIndex ($listbox, 3, 1)
$ret = _GUICtrlListGetCaretIndex ($listbox)
GUICtrlSetData($label, "Item : " & $ret)
EndSelect
WEnd


Function _GUICtrlListSetHorizontalExtent

Function Reference

_GUICtrlListSetHorizontalExtent

Set the width, in pixels, by which a list box can be scrolled horizontally

#Include <GuiList.au3>
_GUICtrlListSetHorizontalExtent ( $h_listbox )

Parameters

$h_listbox | control id/control hWnd
$i_pixels | Specifies the number of pixels by which the list box can be scrolled.

Return Value

None.

Remarks

The list box must have been defined with the $WS_HSCROLL style.

Related

_GUICtrlListGetHorizontalExtent

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt ('MustDeclareVars', 1)

Dim $msg, $listbox, $label

GUICreate("ListBox Set Horizontal Extent", 400, 250, -1, -1)

$listbox = GUICtrlCreateList("", 125, 40, 100, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_DISABLENOSCROLL, $WS_HSCROLL))
_GUICtrlListSetHorizontalExtent ($listbox, 120)
GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|test2|test3|test4|test5|test6|test7|test8|")
$label = GUICtrlCreateLabel("HorizontalExtent: " & _GUICtrlListGetHorizontalExtent ($listbox), 150, 210, 120)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd


Function _GUICtrlListSetLocale

Function Reference

_GUICtrlListSetLocale

Set the locale

#Include <GuiList.au3>
_GUICtrlListSetLocale ( $h_listbox, $s_locale )

Parameters

$h_listbox | control id/control hWnd
$s_locale | Locale

Return Value

Returns previous locale or $LB_ERR

Remarks

"0409" for U.S. English
see @OSLang for string values

Related

_GUICtrlListGetLocale

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt('MustDeclareVars',1)

Dim $msg, $ret,$listbox,$button,$button2

GUICreate("ListBox Get Locale Demo",400,250,-1,-1)
$listbox = GUICtrlCreateList("",125,40,180,120)
GUICtrlSetData($listbox,"test1|more testing|even more testing|demo|test2|test3|test4|test5|test6|test7|test8|test9|test10")
$button = GUICtrlCreateButton('Set Locale English',85,160,120,40)
$button2 = GUICtrlCreateButton('Set Locale Spanish',210,160,120,40)

GUISetState ()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$ret = _GUICtrlListSetLocale($listbox,"0409") ; U.S. English
If($ret == $LB_ERR) Then
MsgBox(16,"Error","Unknown error from _GUICtrlListSetLocale")
Else
MsgBox(0,"Previous Locale",$ret)
EndIf
Case $msg = $button2
$ret = _GUICtrlListSetLocale($listbox,"040a") ;Spanish_Traditional_Sort
If($ret == $LB_ERR) Then
MsgBox(16,"Error","Unknown error from _GUICtrlListSetLocale")
Else
MsgBox(0,"Previous Locale",$ret)
EndIf
EndSelect
Wend


Function _GUICtrlListSetSel

Function Reference

_GUICtrlListSetSel

Select string(s) in a multiple-selection list box

#Include <GuiList.au3>
_GUICtrlListSetSel ( $h_listbox [, $i_flag=-1 [, $i_index = -1 ]] )

Parameters

$h_listbox | control id/control hWnd
$i_flag | Optional: Select/UnSelect
$i_index | Optional: Specifies the zero-based index of the item

Return Value

If an error occurs, the return value is $LB_ERR

Remarks

DOES NOT WORK WITH SINGLE-SELECTION LIST BOXES
$i_flag == 0 means unselect
$i_flag == 1 means select
$i_flag == -1 means toggle select/unselect of item
An $i_index of -1 means to toggle select/unselect of all items (ignores the $i_flag).

Related

_GUICtrlListSelectString, _GUICtrlListGetSelState, _GUICtrlListGetSelCount, _GUICtrlListGetSelItems, _GUICtrlListSelItemRange, _GUICtrlListSelItemRangeEx

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt('MustDeclareVars',1)

Dim $msg, $ret
Dim $listbox,$button,$i,$button2,$button3

GUICreate("ListBox Set Selection(s) Demo",400,250,-1,-1)

$listbox = GUICtrlCreateList("",125,40,180,120,BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY,$LBS_MULTIPLESEL))
GUICtrlSetData($listbox,"test1|more testing|even more testing|demo|test2|test3|test4|test5|test6|test7|test8|test9|test10")
$button = GUICtrlCreateButton("Toggle All",85,160,120,40)
$button2 = GUICtrlCreateButton("Set index 3",215,160,120,40)
$button3 = GUICtrlCreateButton("Toggle index 3",150,210,120,40)

GUISetState ()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$ret = _GUICtrlListSetSel($listbox)
If($ret == $LB_ERR) Then
MsgBox(16,"Error","Unknown error from _GUICtrlListSetSel")
EndIf
Case $msg = $button2
$ret = _GUICtrlListSetSel($listbox,1,3)
If($ret == $LB_ERR) Then
MsgBox(16,"Error","Unknown error from _GUICtrlListSetSel")
EndIf
Case $msg = $button3
$ret = _GUICtrlListSetSel($listbox,-1,3)
If($ret == $LB_ERR) Then
MsgBox(16,"Error","Unknown error from _GUICtrlListSetSel")
EndIf
EndSelect
Wend


Function _GUICtrlListSetTopIndex

Function Reference

_GUICtrlListSetTopIndex

Ensure that a particular item in a list box is visible

#Include <GuiList.au3>
_GUICtrlListSetTopIndex ( $h_listbox, $i_index )

Parameters

$h_listbox | control id/control hWnd
$i_index | Specifies the zero-based index of the item

Return Value

If an error occurs, the return value is $LB_ERR

Remarks

None.

Related

_GUICtrlListGetTopIndex

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt('MustDeclareVars',1)

Dim $msg, $ret
Dim $listbox,$button,$i

GUICreate("ListBox Set Top Index Demo",400,250,-1,-1)

$listbox = GUICtrlCreateList("",125,40,180,120)
GUICtrlSetData($listbox,"test1|more testing|even more testing|demo|test2|test3|test4|test5|test6|test7|test8|test9|test10")
$button = GUICtrlCreateButton("Set Top Index to 4",150,160,120,40)

GUISetState ()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$ret = _GUICtrlListSetTopIndex($listbox,4)
If($ret == $LB_ERR) Then
MsgBox(16,"Error","Unknown error from _GUICtrlListSetTopIndex")
EndIf
EndSelect
Wend


Function _GUICtrlListSort

Function Reference

_GUICtrlListSort

Re-sorts list box if it has the $LBS_SORT style

#Include <GuiList.au3>
_GUICtrlListSort ( $h_listbox )

Parameters

$h_listbox control id/control hWnd

Return Value

If an error occurs, the return value is $LB_ERR

Remarks

Re-sorts list box if it has the $LBS_SORT style
Might be useful if you use InsertString

Related

None.

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt('MustDeclareVars',1)

Dim $msg, $ret,$listbox,$button

GUICreate("ListBox Sort Demo",400,250,-1,-1)

$listbox = GUICtrlCreateList("",125,40,180,120,BitOR($WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY,$LBS_MULTIPLESEL))
GUICtrlSetData($listbox,"test1|more testing|even more testing|demo|test2|test3|test4|test5|test6|test7|test8|test9|test10")
$button = GUICtrlCreateButton('Sort',150,160,120,40)

GUISetState ()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$ret = _GUICtrlListSort($listbox)
If($ret == $LB_ERR) Then
MsgBox(16,"Error","Unknown error from _GUICtrlListBoxSort")
EndIf
EndSelect
Wend


Function _GUICtrlListSwapString

Function Reference

_GUICtrlListSwapString

Swaps the text of two items at the specified indices

#Include <GuiList.au3>
_GUICtrlListSwapString ( $h_listbox, $i_indexA, $i_indexB )

Parameters

$h_listbox | control id/control hWnd
$i_indexA | Zero-based index item to swap
$i_indexB | Zero-based index item to swap

Return Value

If an error occurs, the return value is $LB_ERR

Remarks

None.

Related

None.

Example

#include <GUIConstants.au3>
#include <GuiList.au3>

Opt('MustDeclareVars',1)

Dim $msg, $ret,$listbox,$button

GUICreate("ListBox Swap String Demo",400,250,-1,-1)

$listbox = GUICtrlCreateList("",125,40,180,120,BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY,$LBS_MULTIPLESEL))
GUICtrlSetData($listbox,"test1|more testing|even more testing|demo|test2|test3|test4|test5|test6|test7|test8|test9|test10")
$button = GUICtrlCreateButton('Swap Strings on Indexes 3,5',140,160,150,40)

GUISetState ()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$ret = _GUICtrlListSwapString($listbox,3,5)
If($ret == $LB_ERR) Then
MsgBox(16,"Error","Unknown error from _GUICtrlListSwapString")
EndIf
EndSelect
Wend


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: GuiListView Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_GUICtrlListViewCopyItems | Copy Items between 2 list-view controls
_GUICtrlListViewDeleteAllItems | Removes all items from a list-view control
_GUICtrlListViewDeleteColumn | Removes a column from a list-view control
_GUICtrlListViewDeleteItem | Removes an item from a list-view control
_GUICtrlListViewDeleteItemsSelected | Deletes item(s) selected
_GUICtrlListViewEnsureVisible | Ensures that a list-view item is either entirely or partially visible
_GUICtrlListViewFindItem | Retrieves some or all of a list-view item
_GUICtrlListViewGetBackColor | Retrieves the background color of a list-view control
_GUICtrlListViewGetCallBackMask | Retrieves the callback mask for a list-view control
_GUICtrlListViewGetCheckedState | Returns the check state for a list-view control item
_GUICtrlListViewGetColumnOrder | Retrieves the current left-to-right order of columns in a list-view control.
_GUICtrlListViewGetColumnWidth | Retrieves the width of a column in report or list view
_GUICtrlListViewGetCounterPage | Calculates the number of items that can fit vertically in the visible area of a list-view control
_GUICtrlListViewGetCurSel | Retrieve the index of current selection
_GUICtrlListViewGetExtendedListViewStyle | Retrieves the extended styles that are currently in use for a given list-view control
_GUICtrlListViewGetHeader | Retrieves the handle to the header control used by the list-view control
_GUICtrlListViewGetHotCursor | Retrieves the HCURSOR value used when the pointer is over an item while hot tracking is enabled
_GUICtrlListViewGetHotItem | Retrieves the index of the hot item
_GUICtrlListViewGetHoverTime | Retrieves the amount of time that the mouse cursor must hover over an item before it is selected
_GUICtrlListViewGetItemCount | Retrieves the number of items in a list-view control
_GUICtrlListViewGetItemText | Retrieves some or all of a list-view item
_GUICtrlListViewGetItemTextArray | Retrieves all of a list-view item
_GUICtrlListViewGetNextItem | Returns the index of the next item
_GUICtrlListViewGetSelectedCount | Determines the number of selected items in a list-view control
_GUICtrlListViewGetSelectedIndices | Retrieve indices of selected item(s) in a list-view control
_GUICtrlListViewGetSubItemsCount | Retrieve the number of columns
_GUICtrlListViewGetTopIndex | Retrieves the index of the topmost visible item when in list or report view
_GUICtrlListViewGetUnicodeFormat | Retrieves the UNICODE character format flag for the control
_GUICtrlListViewHideColumn | Hides the column "sets column width to zero"
_GUICtrlListViewInsertColumn | Inserts a column into a list-view control
_GUICtrlListViewInsertItem | Inserts a new item in a list-view control.
_GUICtrlListViewJustifyColumn | Set Justification of a column for a list-view control
_GUICtrlListViewScroll | Scrolls the content of a list-view control
_GUICtrlListViewSetCheckState | Sets the checked state of a list-view control item
_GUICtrlListViewSetColumnHeaderText | Change the text of a column header for a list-view control
_GUICtrlListViewSetColumnOrder | Sets the left-to-right order of columns in a list-view control.
_GUICtrlListViewSetColumnWidth | Changes the width of a column
_GUICtrlListViewSetHotItem | Sets the hot item for a list-view control
_GUICtrlListViewSetHoverTime | Sets the amount of time which the mouse cursor must hover over an item before it is selected
_GUICtrlListViewSetItemCount | Causes the list-view control to allocate memory for the specified number of items.
_GUICtrlListViewSetItemSelState | Sets the Item Selected/UnSelected
_GUICtrlListViewSetItemText | Changes the text of a list-view item or subitem.
_GUICtrlListViewSort | Sorts a list-view control.


Function _GUICtrlListViewCopyItems

Function Reference

_GUICtrlListViewCopyItems

Copy Items between 2 list-view controls

#Include <GuiListView.au3>
_GUICtrlListViewCopyItems ( $h_Source_listview, $h_Destination_listview [, $i_DelFlag = 0 ] )

Parameters

$h_Source_listview | control id/control hWnd
$h_Destination_listview | control id/control hWnd
$i_DelFlag | Optional: Delete after copying (Default: 0)

Return Value

None

Remarks

This will work with/with-out checkboxes in the list-view control

Related

_GUICtrlListViewDeleteAllItems, _GUICtrlListViewDeleteItem, _GUICtrlListViewDeleteItemsSelected

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ("GUIOnEventMode", 1)
Opt ('MustDeclareVars', 1)

Dim $listview, $listview2, $Btn_MoveLeft, $Btn_MoveRight, $Btn_Exit1, $Btn_Exit2, $msg, $GUI1, $GUI2
Dim $Btn_CopyRight, $Btn_CopyLeft
Dim $OptionsMenu, $OptionsItem1, $OptionsItem2, $separator1, $OptionsItem3, $OptionsItem4
Dim $Dock = 1, $Dock_Location = 1, $x1, $x2, $y1, $y2

$GUI1 = GUICreate("GuiListView Copy Items", 300, 220, 10, 10)
$OptionsMenu = GUICtrlCreateMenu("Options")
$OptionsItem1 = GUICtrlCreateMenu("Docking", $OptionsMenu)

$OptionsItem2 = GUICtrlCreateMenuItem("Docked", $OptionsItem1)
$separator1 = GUICtrlCreateMenuItem("", $OptionsItem1)
$OptionsItem3 = GUICtrlCreateMenuItem("Side By Side", $OptionsItem1)
$OptionsItem4 = GUICtrlCreateMenuItem("Top And Bottom", $OptionsItem1)
GUICtrlSetState($OptionsItem2, $GUI_CHECKED)
GUICtrlSetState($OptionsItem3, $GUI_CHECKED)
GUICtrlSetOnEvent($OptionsItem2, "_SetDocking")
GUICtrlSetOnEvent($OptionsItem3, "_SetDockSideBySide")
GUICtrlSetOnEvent($OptionsItem4, "_SetDockTopAndBottom")

GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")

$listview = GUICtrlCreateListView("col1|col2|col3", 5, 5, 150, 185, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
_GUICtrlListViewSetColumnWidth ($listview, 0, 60)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_CHECKBOXES, $LVS_EX_CHECKBOXES)

$Btn_MoveRight = GUICtrlCreateButton("Move", 175, 35, 90, 20)
GUICtrlSetOnEvent($Btn_MoveRight, "_MoveRight")

$Btn_CopyRight = GUICtrlCreateButton("Copy", 175, 60, 90, 20)
GUICtrlSetOnEvent($Btn_CopyRight, "_CopyRight")

$Btn_Exit1 = GUICtrlCreateButton("Exit", 175, 140, 90, 25)
GUICtrlSetOnEvent($Btn_Exit1, "_Exit")

$GUI2 = GUICreate("Right/Bottom Window", 300, 220, 315, 10)

GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")

$Btn_MoveLeft = GUICtrlCreateButton("Move", 175, 55, 90, 20)
GUICtrlSetOnEvent($Btn_MoveLeft, "_MoveLeft")

$Btn_CopyLeft = GUICtrlCreateButton("Copy", 175, 80, 90, 20)
GUICtrlSetOnEvent($Btn_CopyLeft, "_CopyLeft")

$Btn_Exit2 = GUICtrlCreateButton("Exit", 175, 160, 90, 25)
GUICtrlSetOnEvent($Btn_Exit2, "_Exit")

$listview2 = GUICtrlCreateListView("col1|col2|col3", 5, 25, 150, 185, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
_GUICtrlListViewSetColumnWidth ($listview2, 0, 60)
GUICtrlSendMsg($listview2, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview2, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($listview2, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_CHECKBOXES, $LVS_EX_CHECKBOXES)

GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)

GUISetState(@SW_SHOW, $GUI2)
GUISetState(@SW_SHOW, $GUI1)

While 1
If $Dock Then _KeepWindowsDocked()
Sleep(10)
WEnd

Func _SetDocking()
If BitAND(GUICtrlRead($OptionsItem2), $GUI_CHECKED) = $GUI_CHECKED Then
GUICtrlSetState($OptionsItem2, $GUI_UNCHECKED)
$Dock = 0
Else
GUICtrlSetState($OptionsItem2, $GUI_CHECKED)
$Dock = 2
EndIf
If $Dock Then _KeepWindowsDocked()
EndFunc ;==>_SetDocking

Func _SetDockSideBySide()
If BitAND(GUICtrlRead($OptionsItem3), $GUI_CHECKED) = $GUI_CHECKED Then
GUICtrlSetState($OptionsItem3, $GUI_UNCHECKED)
GUICtrlSetState($OptionsItem4, $GUI_CHECKED)
$Dock_Location = 2
Else
GUICtrlSetState($OptionsItem3, $GUI_CHECKED)
GUICtrlSetState($OptionsItem4, $GUI_UNCHECKED)
$Dock_Location = 1
If $Dock Then $Dock = 2
EndIf
If $Dock Then _KeepWindowsDocked()
EndFunc ;==>_SetDockSideBySide

Func _SetDockTopAndBottom()
If BitAND(GUICtrlRead($OptionsItem4), $GUI_CHECKED) = $GUI_CHECKED Then
GUICtrlSetState($OptionsItem4, $GUI_UNCHECKED)
GUICtrlSetState($OptionsItem3, $GUI_CHECKED)
$Dock_Location = 1
Else
GUICtrlSetState($OptionsItem4, $GUI_CHECKED)
GUICtrlSetState($OptionsItem3, $GUI_UNCHECKED)
$Dock_Location = 2
If $Dock Then $Dock = 2
EndIf
If $Dock Then _KeepWindowsDocked()
EndFunc ;==>_SetDockTopAndBottom

Func _KeepWindowsDocked()
Local $p_win1 = WinGetPos($GUI1)
Local $p_win2 = WinGetPos($GUI2)
If $Dock_Location == 1 Then
If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 8) Or $Dock = 2) Then
$x1 = $p_win1[0]
$y1 = $p_win1[1]
$x2 = $p_win1[2] + $x1
$y2 = $y1
WinMove($GUI2, "", $x2, $y2)
$Dock = 1
ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 8)) Then
$x2 = $p_win2[0]
$y2 = $p_win2[1]
$x1 = $p_win2[0] - $p_win1[2]
$y1 = $y2
WinMove($GUI1, "", $x1, $y1)
EndIf
Else
If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 8) Or $Dock = 2) Then
$x1 = $p_win1[0]
$y1 = $p_win1[1]
$x2 = $x1
$y2 = $p_win1[3] + $y1
WinMove($GUI2, "", $x2, $y2)
$Dock = 1
ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 8)) Then
$x2 = $p_win2[0]
$y2 = $p_win2[1]
$x1 = $x2
$y1 = $p_win2[1] - $p_win1[3]
WinMove($GUI1, "", $x1, $y1)
EndIf
EndIf
EndFunc ;==>_KeepWindowsDocked

Func _CopyRight()
_GUICtrlListViewCopyItems ($listview, $listview2)
EndFunc ;==>_CopyRight

Func _MoveRight()
_GUICtrlListViewCopyItems ($listview, $listview2, 1)
EndFunc ;==>_MoveRight

Func _CopyLeft()
_GUICtrlListViewCopyItems ($listview2, $listview)
EndFunc ;==>_CopyLeft

Func _MoveLeft()
_GUICtrlListViewCopyItems ($listview2, $listview, 1)
EndFunc ;==>_MoveLeft

Func _Exit()
Exit
EndFunc ;==>_Exit

Func SpecialEvents()
Select
Case @GUI_CtrlId = $GUI_EVENT_CLOSE
Exit
EndSelect
EndFunc ;==>SpecialEvents


Function _GUICtrlListViewDeleteAllItems

Function Reference

_GUICtrlListViewDeleteAllItems

Removes all items from a list-view control

#Include <GuiListView.au3>
_GUICtrlListViewDeleteAllItems ( $h_listview )

Parameters

$h_listview control id/control hWnd

Return Value

Returns TRUE if successful, or FALSE otherwise

Remarks

Related

_GUICtrlListViewDeleteItem, _GUICtrlListViewDeleteItemsSelected, _GUICtrlListViewDeleteColumn

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_DeleteAll, $Btn_Exit, $msg, $ret, $Status
GUICreate("ListView Delete All Items", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
$Btn_DeleteAll = GUICtrlCreateButton("Delete All Items", 150, 200, 90, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_DeleteAll
If (_GUICtrlListViewDeleteAllItems ($listview)) Then
GUICtrlSetData($Status, 'Deleted All Items')
Else
GUICtrlSetData($Status, 'Delete Failed')
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlListViewDeleteColumn

Function Reference

_GUICtrlListViewDeleteColumn

Removes a column from a list-view control

#Include <GuiListView.au3>
_GUICtrlListViewDeleteColumn ( $h_listview, $i_col )

Parameters

$h_listview | control id/control hWnd
$i_col | Index of the column to delete

Return Value

Returns TRUE if successful, or FALSE otherwise

Remarks

Column zero of the list-view control cannot be deleted.
If you must delete column zero, insert a zero length dummy
column zero and delete column one and above

Related

_GUICtrlListViewDeleteAllItems, _GUICtrlListViewDeleteItem, _GUICtrlListViewDeleteItemsSelected, _GUICtrlListViewGetSubItemsCount

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_DeleteCol, $Btn_Exit, $msg, $Input_col, $Status
GUICreate("ListView Delete Column", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
GUICtrlCreateLabel("Enter Column # to Delete:", 90, 190, 130, 20)
$Input_col = GUICtrlCreateInput("", 220, 190, 80, 20, $ES_NUMBER)
GUICtrlSetLimit($Input_col, 1)
$Btn_DeleteCol = GUICtrlCreateButton("Delete Column", 150, 230, 90, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Status = GUICtrlCreateLabel("Remember columns are zero-indexed", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_DeleteCol
If (StringLen(GUICtrlRead($Input_col)) > 0) Then
If (_GUICtrlListViewDeleteColumn ($listview, Int(GUICtrlRead($Input_col)))) Then
GUICtrlSetData($Status, 'Deleted column: ' & GUICtrlRead($Input_col) & ' Successful')
Else
GUICtrlSetData($Status, 'Failed to Delete column: ' & GUICtrlRead($Input_col))
EndIf
Else
GUICtrlSetData($Status, 'Must enter a column to delete')
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlListViewDeleteItem

Function Reference

_GUICtrlListViewDeleteItem

Removes an item from a list-view control

#Include <GuiListView.au3>
_GUICtrlListViewDeleteItem ( $h_listview, $i_index )

Parameters

$h_listview | control id/control hWnd
$i_index | Index of the list-view item to delete

Return Value

Returns TRUE if successful, or FALSE otherwise

Remarks

None.

Related

_GUICtrlListViewDeleteAllItems, _GUICtrlListViewDeleteItemsSelected, _GUICtrlListViewDeleteColumn

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_DeleteItem, $Btn_Exit, $msg, $Input_item, $Status
GUICreate("ListView Delete Item", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
GUICtrlCreateLabel("Enter Item # to Delete:", 90, 190, 130, 20)
$Input_item = GUICtrlCreateInput("", 220, 190, 80, 20, $ES_NUMBER)
GUICtrlSetLimit($Input_item, 1)
$Btn_DeleteItem = GUICtrlCreateButton("Delete Item", 150, 230, 90, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Status = GUICtrlCreateLabel("Remember items are zero-indexed", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_DeleteItem
If (StringLen(GUICtrlRead($Input_item)) > 0) Then
If (_GUICtrlListViewDeleteItem ($listview, Int(GUICtrlRead($Input_item)))) Then
GUICtrlSetData($Status, 'Delete item: ' & GUICtrlRead($Input_item) & ' Successful')
Else
GUICtrlSetData($Status, 'Failed to Delete item: ' & GUICtrlRead($Input_item))
EndIf
Else
GUICtrlSetData($Status, 'Must enter a item to delete')
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlListViewDeleteItemsSelected

Function Reference

_GUICtrlListViewDeleteItemsSelected

Deletes item(s) selected

#Include <GuiListView.au3>
_GUICtrlListViewDeleteItemsSelected ( $h_listview )

Parameters

$h_listview control id/control hWnd

Return Value

None.

Remarks

None.

Related

_GUICtrlListViewDeleteAllItems, _GUICtrlListViewDeleteItem, _GUICtrlListViewDeleteColumn

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_DeleteItems, $Btn_Exit, $msg
GUICreate("ListView Delete Items Selected", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER))
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
$Btn_DeleteItems = GUICtrlCreateButton("Delete Items Selected", 150, 230, 120, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_DeleteItems
_GUICtrlListViewDeleteItemsSelected ($listview)
EndSelect
WEnd
Exit


Function _GUICtrlListViewEnsureVisible

Function Reference

_GUICtrlListViewEnsureVisible

Ensures that a list-view item is either entirely or partially visible

#Include <GuiListView.au3>
_GUICtrlListViewEnsureVisible ( $h_listview, $i_index, $i_bool )

Parameters

$h_listview | control id/control hWnd
$i_index | Index of the list-view item
$i_bool | Value specifying whether the item must be entirely visible

Return Value

Returns TRUE if successful, or FALSE otherwise

Remarks

If $i_bool parameter is TRUE, no scrolling occurs if the item is at least partially visible

Related

None.

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $msg, $i, $Styles, $Btn_visible, $i
GUICreate("ListView Ensure Visible", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 144)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
For $i = 1 To 20
GUICtrlCreateListViewItem("line" & $i & "|data" & $i & "|more" & $i, $listview)
Next
$Btn_visible = GUICtrlCreateButton("Set Visible", 150, 230, 90, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_visible
_GUICtrlListViewEnsureVisible($listview, 12, 1)
EndSelect
WEnd
Exit


Function _GUICtrlListViewFindItem

Function Reference

_GUICtrlListViewFindItem

Retrieves some or all of a list-view item

#Include <GuiListView.au3>
_GUICtrlListViewFindItem ( $h_listview, $v_find [, $i_Start = -1 [, $v_SearchType = 0x8 [, $v_direction = 0x28 ]]] )

Parameters

$h_listview | controlID
$v_find | Text/Item Id to find (See Notes)
$i_Start | Optional: Index of the item to begin the search with or -1 to start from the beginning. The specified item is itself excluded from the search. (Default -1)
$v_SearchType | Type of search to perform (See Notes)
$v_direction | Virtual key code that specifies the direction to search (See Notes)

Return Value

Returns index if successful, or -1 otherwise

Remarks

$v_SearchType:
$LVFI_PARAM
Search by Item Id
$LVFI_PARTIAL (Default)
Checks to see if the item text begins with the string pointed to by the psz member.
This value implies use of $LVFI_STRING.
$LVFI_STRING
Searches based on the item text.
Unless additional values are specified, the item text of the matching item must exactly
match the string pointed to by the psz member. However, the search is case-insensitive.
$LVFI_WRAP
Continues the search at the beginning if no match is found

$v_direction
$VK_LEFT
$VK_RIGHT
$VK_UP
$VK_DOWN
$VK_HOME
$VK_END

Related

_GUICtrlListViewCopyItems, _GUICtrlListViewDeleteItem, _GUICtrlListViewGetItemText

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt('MustDeclareVars', 1)
Dim $listview, $Btn_FindExact, $Btn_FindPartial, $Btn_FindByID, $Btn_Exit, $msg, $ret, $input_find, $index, $item[5]
GUICreate("ListView Find Item", 392, 322)

$listview = GUICtrlCreateListView("Fruit|Item Id", 40, 30, 310, 149, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
$item[0] = GUICtrlCreateListViewItem("orange|", $listview)
$item[1] = GUICtrlCreateListViewItem("apple|", $listview)
$item[2] = GUICtrlCreateListViewItem("lime|", $listview)
$item[3] = GUICtrlCreateListViewItem("tangerine|", $listview)
$item[4] = GUICtrlCreateListViewItem("banana|", $listview)
For $x = 0 To UBound($item) - 1
_GUICtrlListViewSetItemText($listview, $x, 1, $item[$x])
Next
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
_GUICtrlListViewSetColumnWidth($listview, 0, 100)
$input_find = GUICtrlCreateInput("", 40, 200, 200, 20)
$Btn_FindPartial = GUICtrlCreateButton("Find (Partial)", 40, 230, 90, 30)
$Btn_FindExact = GUICtrlCreateButton("Find (Exact)", 145, 230, 90, 30)
$Btn_FindByID = GUICtrlCreateButton("Find by ID", 95, 270, 90, 30)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_FindPartial
$index = _GUICtrlListViewFindItem ($listview, GUICtrlRead($input_find), -1, BitOR($LVFI_PARTIAL, $LVFI_WRAP))
If $index = $LV_ERR Then
MsgBox(0, "Find Partial", "Error")
Else
MsgBox(0, "Find Partial", "Index: " & $index)
EndIf
Case $msg = $Btn_FindExact
$index = _GUICtrlListViewFindItem ($listview, GUICtrlRead($input_find), -1, BitOR($LVFI_STRING, $LVFI_WRAP))
If $index = $LV_ERR Then
MsgBox(0, "Find Exact", "Error")
Else
MsgBox(0, "Find Exact", "Index: " & $index)
EndIf
Case $msg = $Btn_FindByID
$index = _GUICtrlListViewFindItem ($listview, GUICtrlRead($input_find), -1, BitOR($LVFI_PARAM, $LVFI_WRAP))
If $index = $LV_ERR Then
MsgBox(0, "Find by ID", "Error")
Else
MsgBox(0, "Find by ID", "Index: " & $index)
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlListViewGetBackColor

Function Reference

_GUICtrlListViewGetBackColor

Retrieves the background color of a list-view control

#Include <GuiListView.au3>
_GUICtrlListViewGetBackColor ( $h_listview )

Parameters

$h_listview control id/control hWnd

Return Value

Returns the Hex RGB background color of the list-view control

Remarks

None.

Related

None.

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $msg, $Status
GUICreate("ListView Get BackColor", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER))
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
$Btn_Exit = GUICtrlCreateButton("Exit", 150, 260, 70, 30)
$Status = GUICtrlCreateLabel("ListView BackColor: " & _GUICtrlListViewGetBackColor ($listview), 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
EndSelect
WEnd
Exit


Function _GUICtrlListViewGetCallBackMask

Function Reference

_GUICtrlListViewGetCallBackMask

Retrieves the callback mask for a list-view control

#Include <GuiListView.au3>
_GUICtrlListViewGetCallBackMask ( $h_listview )

Parameters

$h_listview control id/control hWnd

Return Value

Returns the callback mask

Remarks

None.

Related

None.

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $msg, $Status, $pos
GUICreate("ListView Get CallBack Mask", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER))
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
$Btn_Exit = GUICtrlCreateButton("Exit", 150, 260, 70, 30)
$Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $GUI_EVENT_PRIMARYDOWN
$pos = GUIGetCursorInfo()
If ($pos[4] == $listview) Then
GUICtrlSetData($Status, "ListView Call Back Mask: " & _GUICtrlListViewGetCallBackMask ($listview))
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlListViewGetCheckedState

Function Reference

_GUICtrlListViewGetCheckedState

Returns the check state for a list-view control item

#Include <GuiListView.au3>
_GUICtrlListViewGetCheckedState ( $h_listview, $i_index )

Parameters

$h_listview | control id/control hWnd
$i_index | zero-based index to retrieve item check state from

Return Value

Returns 1 if checked
Returns 0 if not checked
If error then $LV_ERR is returned

Remarks

Requires $LVS_EX_CHECKBOXES to be used in extended style when creating listview

Related

_GUICtrlListViewGetCurSel

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

opt('MustDeclareVars', 1)
Dim $listview, $Btn_Get, $Btn_Exit, $msg, $Status, $ret
GUICreate("ListView Get Checked State", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_CHECKBOXES, $LVS_EX_CHECKBOXES)
GUICtrlCreateListViewItem("index 0|data1|more1", $listview)
GUICtrlCreateListViewItem("index 1|data2|more2", $listview)
GUICtrlCreateListViewItem("index 2|data3|more3", $listview)
GUICtrlCreateListViewItem("index 3|data4|more4", $listview)
GUICtrlCreateListViewItem("index 4|data5|more5", $listview)
_GUICtrlListViewSetColumnWidth ($listview, 0, 100)
$Btn_Get = GUICtrlCreateButton("Get From Index 2", 150, 200, 90, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_Get
GUICtrlSetData($Status, "")
Local $is_Checked = _GUICtrlListViewGetCheckedState ($listview, 2)
If ($is_Checked <> $LV_ERR) Then
If ($is_Checked) Then
GUICtrlSetData($Status, "Item is Checked")
Else
GUICtrlSetData($Status, "Item not Checked")
EndIf
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlListViewGetColumnOrder

Function Reference

_GUICtrlListViewGetColumnOrder

Retrieves the current left-to-right order of columns in a list-view control.

#Include <GuiListView.au3>
_GUICtrlListViewGetColumnOrder ( $h_listview )

Parameters

$h_listbox control id/control hWnd

Return Value

"|" delimited string
If an error occurs, the return value is $LV_ERR.

Remarks

None.

Related

_GUICtrlListViewGetSubItemsCount, _GUICtrlListViewSetColumnOrder

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

opt('MustDeclareVars', 1)

Dim $listview, $button, $msg, $i, $a_order, $hList

;================================================================
; Example 1 - Get Column Order from AutoIt Control
;================================================================
GUICreate("ListView Get Column Order", 392, 254)
$listview = GUICtrlCreateListView("col1|col2|col3|col4", 100, 10, 200, 100, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER))
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_HEADERDRAGDROP, $LVS_EX_HEADERDRAGDROP)
$button = GUICtrlCreateButton("Get Order", 150, 120, 90, 30)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$a_order = StringSplit(_GUICtrlListViewGetColumnOrder($listview),"|")
For $i = 1 To $a_order[0]
MsgBox(0, "col", $a_order[$i])
Next
EndSelect
WEnd
GUIDelete()

;================================================================
; Example 2 - Get Column Order from System Control
;================================================================
Run("explorer.exe /root, ,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")
WinWaitActive("My Computer")
$hList = ControlGetHandle("My Computer", "", "SysListView321")
$a_order = StringSplit( _GUICtrlListViewGetColumnOrder($hList),"|")
For $i = 1 To $a_order[0]
MsgBox(0, "col", $a_order[$i])
Next


Function _GUICtrlListViewGetColumnWidth

Function Reference

_GUICtrlListViewGetColumnWidth

Retrieves the width of a column in report or list view

#Include <GuiListView.au3>
_GUICtrlListViewGetColumnWidth ( $h_listview, $i_col )

Parameters

$h_listview | control id/control hWnd
$i_col | Index of the column. This parameter is ignored in list view

Return Value

Returns the column width if successful, or zero otherwise

Remarks

If this message is sent to a list-view control with the $LVS_REPORT style
and the specified column doesn't exist, the return value is undefined

Related

_GUICtrlListViewHideColumn, _GUICtrlListViewSetColumnWidth, _GUICtrlListViewDeleteColumn

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $msg, $Status, $pos
GUICreate("ListView Get Column Width", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
$Btn_Exit = GUICtrlCreateButton("Exit", 150, 260, 70, 30)
$Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $GUI_EVENT_PRIMARYUP
GUICtrlSetData($Status, "col1 width: " & _GUICtrlListViewGetColumnWidth ($listview, 0) & ", col2 width: " & _GUICtrlListViewGetColumnWidth ($listview, 1) & ", col3 width: " & _GUICtrlListViewGetColumnWidth ($listview, 2))
EndSelect
WEnd
Exit


Function _GUICtrlListViewGetCounterPage

Function Reference

_GUICtrlListViewGetCounterPage

Calculates the number of items that can fit vertically in the visible area of a list-view control

#Include <GuiListView.au3>
_GUICtrlListViewGetCounterPage ( $h_listview )

Parameters

$h_listview control id/control hWnd

Return Value

Returns the number of fully visible items if successful.

Remarks

None.

Related

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $msg, $Status
GUICreate("ListView Get Counter Page", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER))
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
$Btn_Exit = GUICtrlCreateButton("Exit", 150, 260, 70, 30)
$Status = GUICtrlCreateLabel("Possible Fully Visible Rows: " & _GUICtrlListViewGetCounterPage ($listview), 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
EndSelect
WEnd
Exit


Function _GUICtrlListViewGetCurSel

Function Reference

_GUICtrlListViewGetCurSel

Retrieve the index of current selection

#Include <GuiListView.au3>
_GUICtrlListViewGetCurSel ( $h_listview )

Parameters

$h_listview control id/control hWnd

Return Value

Index of current selection (zero-based index)
Returns $LV_ERR if error

Remarks

None.

Related

_GUICtrlListViewGetSelectedCount, _GUICtrlListViewGetItemText, _GUICtrlListViewGetItemTextArray, _GUICtrlListViewGetNextItem

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $msg, $Status, $pos
GUICreate("ListView Get Current Selection", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER))
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
$Btn_Exit = GUICtrlCreateButton("Exit", 150, 260, 70, 30)
$Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $GUI_EVENT_PRIMARYDOWN
$pos = GUIGetCursorInfo()
If ($pos[4] == $listview) Then
GUICtrlSetData($Status, "Current Index Selected: " & _GUICtrlListViewGetCurSel ($listview))
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlListViewGetExtendedListViewStyle

Function Reference

_GUICtrlListViewGetExtendedListViewStyle

Retrieves the extended styles that are currently in use for a given list-view control

#Include <GuiListView.au3>
_GUICtrlListViewGetExtendedListViewStyle ( $h_listview )

Parameters

$h_listview control id/control hWnd

Return Value

Returns a DWORD that represents the styles currently in use for a given list-view control.
This value can be a combination of Extended List-View Styles

Remarks

None.

Related

None.

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $msg, $i, $Styles, $Status, $Btn_Get, $i
GUICreate("ListView Get Extended List View Style", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_HEADERDRAGDROP, $LVS_EX_HEADERDRAGDROP)
For $i = 1 To 20
GUICtrlCreateListViewItem("line" & $i & "|data" & $i & "|more" & $i, $listview)
Next
$Btn_Get = GUICtrlCreateButton("Get Styles", 150, 230, 90, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Status = GUICtrlCreateLabel("Extended List View Style(s): " & _GUICtrlListViewGetExtendedListViewStyle($listview), 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_Get
For $i = 1 to 17
Select
Case $i = 1
If(BitAND(_GUICtrlListViewGetExtendedListViewStyle($listview),$LVS_EX_CHECKBOXES) = $LVS_EX_CHECKBOXES) Then
$Styles &= "$LVS_EX_CHECKBOXES" & @LF
EndIf
Case $i = 2
If(BitAND(_GUICtrlListViewGetExtendedListViewStyle($listview),$LVS_EX_GRIDLINES) = $LVS_EX_GRIDLINES) Then
$Styles &= "$LVS_EX_GRIDLINES" & @LF
EndIf
Case $i = 4
If(BitAND(_GUICtrlListViewGetExtendedListViewStyle($listview),$LVS_EX_HEADERDRAGDROP) = $LVS_EX_HEADERDRAGDROP) Then
$Styles &= "$LVS_EX_HEADERDRAGDROP"
EndIf
EndSelect
Next
If($Styles) Then
MsgBox(0,"Extend Styles found", $Styles)
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlListViewGetHeader

Function Reference

_GUICtrlListViewGetHeader

Retrieves the handle to the header control used by the list-view control

#Include <GuiListView.au3>
_GUICtrlListViewGetHeader ( $h_listview )

Parameters

$h_listview control id/control hWnd

Return Value

Returns the handle to the header control.

Remarks

None.

Related

None.

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $msg, $Status
GUICreate("ListView Edit Lable", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Status = GUICtrlCreateLabel("HeaderID: " & _GUICtrlListViewGetHeader($listview), 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
EndSelect
WEnd
Exit


Function _GUICtrlListViewGetHotCursor

Function Reference

_GUICtrlListViewGetHotCursor

Retrieves the HCURSOR value used when the pointer is over an item while hot tracking is enabled

#Include <GuiListView.au3>
_GUICtrlListViewGetHotCursor ( $h_listview )

Parameters

$h_listview control id/control hWnd

Return Value

Returns an HCURSOR value that is the handle to the cursor that
the list-view control uses when hot tracking is enabled.

Remarks

A list-view control uses hot tracking and hover selection when
the $LVS_EX_TRACKSELECT style is set.

Related

None.

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $msg, $Status
GUICreate("ListView Get Hot Cursor", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 144)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_HEADERDRAGDROP, $LVS_EX_HEADERDRAGDROP)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_TRACKSELECT, $LVS_EX_TRACKSELECT)
For $i = 1 To 20
GUICtrlCreateListViewItem("line" & $i & "|data" & $i & "|more" & $i, $listview)
Next
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Status = GUICtrlCreateLabel("Hot Cursor: " & _GUICtrlListViewGetHotCursor($listview), 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
EndSelect
WEnd
Exit


Function _GUICtrlListViewGetHotItem

Function Reference

_GUICtrlListViewGetHotItem

Retrieves the index of the hot item

#Include <GuiListView.au3>
_GUICtrlListViewGetHotItem ( $h_listview )

Parameters

$h_listview control id/control hWnd

Return Value

Returns the index of the item that is hot.

Remarks

None.

Related

_GUICtrlListViewSetHotItem, _GUICtrlListViewGetHoverTime, _GUICtrlListViewSetHoverTime

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $msg, $Status, $pos, $current
GUICreate("ListView Get Hot Item", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER))
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_TRACKSELECT, $LVS_EX_TRACKSELECT)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
$Btn_Exit = GUICtrlCreateButton("Exit", 150, 260, 70, 30)
$Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
$current = _GUICtrlListViewGetHotItem ($listview)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case Else
$pos = GUIGetCursorInfo()
If ($pos[4] == $listview) Then
If ($current <> _GUICtrlListViewGetHotItem ($listview) And _GUICtrlListViewGetHotItem ($listview) >= 0) Then
GUICtrlSetData($Status, "Hot Item: " & _GUICtrlListViewGetHotItem ($listview))
$current = _GUICtrlListViewGetHotItem ($listview)
ElseIf (_GUICtrlListViewGetHotItem ($listview) == -1) Then
GUICtrlSetData($Status, "")
EndIf
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlListViewGetHoverTime

Function Reference

_GUICtrlListViewGetHoverTime

Retrieves the amount of time that the mouse cursor must hover over an item before it is selected

#Include <GuiListView.au3>
_GUICtrlListViewGetHoverTime ( $h_listview )

Parameters

$h_listview control id/control hWnd

Return Value

Returns the amount of time, in milliseconds.

Remarks

If the return value is -1, then the hover
time is the default hover time.

The hover time only affects list-view controls that have the
$LVS_EX_TRACKSELECT, $LVS_EX_ONECLICKACTIVATE, or
$LVS_EX_TWOCLICKACTIVATE extended list-view style.

Related

_GUICtrlListViewSetHoverTime, _GUICtrlListViewGetHotItem

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $msg, $Status
GUICreate("ListView Get Hover Time", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER))
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_TRACKSELECT, $LVS_EX_TRACKSELECT)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
$Btn_Exit = GUICtrlCreateButton("Exit", 150, 260, 70, 30)
$Status = GUICtrlCreateLabel("Hover Time:" & _GUICtrlListViewGetHoverTime ($listview), 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
EndSelect
WEnd
Exit


Function _GUICtrlListViewGetItemCount

Function Reference

_GUICtrlListViewGetItemCount

Retrieves the number of items in a list-view control

#Include <GuiListView.au3>
_GUICtrlListViewGetItemCount ( $h_listview )

Parameters

$h_listview control id/control hWnd

Return Value

Returns the number of items.

Remarks

None.

Related

_GUICtrlListViewGetItemText, _GUICtrlListViewGetItemTextArray

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $msg, $Status
GUICreate("ListView Get Item Count", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER))
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_TRACKSELECT, $LVS_EX_TRACKSELECT)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
$Btn_Exit = GUICtrlCreateButton("Exit", 150, 260, 70, 30)
$Status = GUICtrlCreateLabel("Item Count: " & _GUICtrlListViewGetItemCount ($listview), 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
EndSelect
WEnd
Exit


Function _GUICtrlListViewGetItemText

Function Reference

_GUICtrlListViewGetItemText

Retrieves some or all of a list-view item

#Include <GuiListView.au3>
_GUICtrlListViewGetItemText ( $h_listview [, $i_Item=-1 [, $i_SubItem=-1 ]] )

Parameters

$h_listview | control id/control hWnd
$i_Item | Index of item to retrieve from (zero-based index)
$i_SubItem | Optional: Column of item to retrieve from (zero-based index)

Return Value

If $i_Item = -1 then current selected index is used
If $i_SubItem = -1 then row is returned pipe delimited
else text from $i_SubItem position is returned
If error then @error is set to $LV_ERR and "" is returned

Remarks

None.

Related

_GUICtrlListViewGetItemTextArray, _GUICtrlListViewGetCurSel, _GUICtrlListViewGetSelectedCount

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt('MustDeclareVars', 1)
Dim $listview, $Btn_Get, $Btn_GetSelected, $Btn_Exit, $msg, $Status, $ret

;================================================================
; Example 1 - Get Text from AutoIt Control
;================================================================
GUICreate("ListView Get Item Text AutoIt Created Control", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
$Btn_Get = GUICtrlCreateButton("Get From Index 2", 75, 200, 90, 40)
$Btn_GetSelected = GUICtrlCreateButton("Get Selected", 200, 200, 90, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_Get
GUICtrlSetData($Status, "")
MsgBox(0, "Passed Item Index only", _GUICtrlListViewGetItemText($listview, 2))
MsgBox(0, "Passed Item Index, SubItem 0", _GUICtrlListViewGetItemText($listview, 2, 0))
Case $msg = $Btn_GetSelected
GUICtrlSetData($Status, "")
$ret = _GUICtrlListViewGetItemText($listview, _GUICtrlListViewGetSelectedIndices($listview))
If ($ret <> $LV_ERR) Then
MsgBox(0, "Selected Item", $ret)
$ret = _GUICtrlListViewGetItemText($listview, _GUICtrlListViewGetSelectedIndices($listview), 0)
If ($ret <> $LV_ERR) Then
MsgBox(0, "Selected Item, SubItem 0", $ret)
EndIf
Else
GUICtrlSetData($Status, "Nothing Selected")
EndIf
EndSelect
WEnd
GUIDelete()

;================================================================
; Example 2 - Get Text from System Control
;================================================================
Dim $h_desktop = ControlGetHandle("Program Manager", "FolderView", 1)
GUICreate("ListView Get Item Text From System Control", 392, 322)

$listview = GUICtrlCreateListView("Items on DeskTop", 40, 30, 310, 149)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
For $x = 0 To _GUICtrlListViewGetItemCount($h_desktop) - 1
GUICtrlCreateListViewItem(_GUICtrlListViewGetItemText($h_desktop, $x, 0), $listview)
Next
_GUICtrlListViewSetColumnWidth($listview,0,$LVSCW_AUTOSIZE)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
EndSelect
WEnd
GUIDelete()


Function _GUICtrlListViewGetItemTextArray

Function Reference

_GUICtrlListViewGetItemTextArray

Retrieves all of a list-view item

#Include <GuiListView.au3>
_GUICtrlListViewGetItemTextArray ( $h_listview [, $i_Item=-1 ] )

Parameters

$h_listview | control id/control hWnd
$i_Item | index of item to retrieve from (zero-based index)

Return Value

If $i_Item = -1 then current selected index is used
Returns an array of the subitems, first element ($array[0]) contains the number of subitems returned
If error $LV_ERR is returned

Remarks

Related

_GUICtrlListViewGetItemText, _GUICtrlListViewGetCurSel, _GUICtrlListViewGetSelectedCount

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_Get, $Btn_GetSelected, $Btn_Exit, $msg, $Status, $a_Item, $i
GUICreate("ListView Get Item Text Array", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
$Btn_Get = GUICtrlCreateButton("Get From Index 2", 75, 200, 90, 40)
$Btn_GetSelected = GUICtrlCreateButton("Get Selected", 200, 200, 90, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_Get
GUICtrlSetData($Status, "")
$a_Item = _GUICtrlListViewGetItemTextArray ($listview, 2)
If (Not IsArray($a_Item)) Then
GUICtrlSetData($Status, "Invalid Item #")
Else
For $i = 1 To $a_Item[0]
MsgBox(0, "Passed Item Index only", "SubItem[" & $i & "] = " & $a_Item[$i])
Next
EndIf
Case $msg = $Btn_GetSelected
GUICtrlSetData($Status, "")
$a_Item = _GUICtrlListViewGetItemTextArray ($listview)
If (Not IsArray($a_Item)) Then
GUICtrlSetData($Status, "Nothing Selected")
Else
For $i = 1 To $a_Item[0]
MsgBox(0, "Passed Item Index only", "SubItem[" & $i & "] = " & $a_Item[$i])
Next
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlListViewGetNextItem

Function Reference

_GUICtrlListViewGetNextItem

Returns the index of the next item

#Include <GuiListView.au3>
_GUICtrlListViewGetNextItem ( $h_GUI, $h_listview [, $i_index=-1 [, $i_direction=0x0 ]] )

Parameters

$h_GUI | GUI windows Handle
$h_listview | control id/control hWnd
$i_index | Optional: Index of the item to begin the search with (default -1)
$i_direction | Optional: Specifies the relationship to the item specified in $i_index (default $LVNI_ALL)

Return Value

Returns the index of the next item if successful, or $LV_ERR otherwise.

Remarks

If $i_index = -1 then find the first item that matches the specified $i_direction.
The specified item itself is excluded from the search.
$i_direction
Searches by index.
$LVNI_ALL Searches for a subsequent item by index, the default value.

Searches by physical relationship to the index of the item where the search is to begin.
$LVNI_ABOVE | Searches for an item that is above the specified item.
$LVNI_BELOW | Searches for an item that is below the specified item.
$LVNI_TOLEFT | Searches for an item to the left of the specified item.
$LVNI_TORIGHT | Searches for an item to the right of the specified item.

Related

_GUICtrlListViewGetItemText, _GUICtrlListViewGetItemTextArray

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_GetAbove, $Btn_GetBelow, $Btn_Exit, $msg, $Status, $GUI
$GUI = GUICreate("ListView Get Next Item", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
$Btn_GetAbove = GUICtrlCreateButton("Get Next Above", 75, 200, 90, 40)
$Btn_GetBelow = GUICtrlCreateButton("Get Next Below", 200, 200, 90, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_GetAbove
GUICtrlSetData($Status, "")
If (_GUICtrlListViewGetCurSel ($listview) > 0) Then
GUICtrlSetData($Status, "Next Above Index: " & _GUICtrlListViewGetNextItem ($GUI, $listview, _GUICtrlListViewGetCurSel ($listview), $LVNI_ABOVE))
Else
GUICtrlSetData($Status, "Nothing Selected or Nothing Above")
EndIf
Case $msg = $Btn_GetBelow
GUICtrlSetData($Status, "")
If (_GUICtrlListViewGetCurSel ($listview) > $LV_ERR And _GUICtrlListViewGetCurSel ($listview) < _GUICtrlListViewGetItemCount ($listview) -1) Then
GUICtrlSetData($Status, "Next Below Index: " & _GUICtrlListViewGetNextItem ($GUI, $listview, _GUICtrlListViewGetCurSel ($listview), $LVNI_BELOW))
Else
GUICtrlSetData($Status, "Nothing Selected or Nothing Below")
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlListViewGetSelectedCount

Function Reference

_GUICtrlListViewGetSelectedCount

Determines the number of selected items in a list-view control

#Include <GuiListView.au3>
_GUICtrlListViewGetSelectedCount ( $h_listview )

Parameters

$h_listview control id/control hWnd

Return Value

Returns the number of selected items

Remarks

None.

Related

_GUICtrlListViewGetItemText, _GUICtrlListViewGetItemTextArray, _GUICtrlListViewGetNextItem

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $msg, $Status, $pos
GUICreate("ListView Get Selected Count", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER))
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
$Btn_Exit = GUICtrlCreateButton("Exit", 150, 260, 70, 30)
$Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $GUI_EVENT_PRIMARYDOWN
$pos = GUIGetCursorInfo()
If ($pos[4] == $listview) Then
GUICtrlSetData($Status, "Selected Count: " & _GUICtrlListViewGetSelectedCount ($listview))
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlListViewGetSelectedIndices

Function Reference

_GUICtrlListViewGetSelectedIndices

Retrieve indices of selected item(s) in a list-view control

#Include <GuiListView.au3>
_GUICtrlListViewGetSelectedIndices ( $h_listview [, $i_ReturnType=0 ] )

Parameters

$h_listview | control id/control hWnd
$i_ReturnType | Optional: return a string or array

Return Value

If $i_ReturnType = 0 then Return pipe delimited string of indices of selected item(s)
If $i_ReturnType = 1 then Return array of indices of selected item(s), first element ($array[0]) contains the number of indices returned
If no items selected return $LV_ERR

Remarks

None.

Related

_GUICtrlListViewGetCurSel, _GUICtrlListViewGetSelectedCount

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $msg, $Status, $Btn_piped, $Btn_array
GUICreate("ListView Get Selected Indices", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER))
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
$Btn_piped = GUICtrlCreateButton("Return string", 75, 210, 90, 30)
$Btn_array = GUICtrlCreateButton("Return array", 180, 210, 90, 30)
$Btn_Exit = GUICtrlCreateButton("Exit", 150, 260, 70, 30)
$Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_piped
Local $s_indices = _GUICtrlListViewGetSelectedIndices($listview)
If($s_indices == $LV_ERR) Then
GUICtrlSetData($Status, "Not Items Selected")
Else
MsgBox(0,"Selected", $s_indices)
EndIf
Case $msg = $Btn_array
Local $a_indices = _GUICtrlListViewGetSelectedIndices($listview,1)
If(IsArray($a_indices))Then
Local $i
For $i = 1 To $a_indices[0]
MsgBox(0,"Selected", $a_indices[$i])
Next
Else
GUICtrlSetData($Status, "Not Items Selected")
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlListViewGetSubItemsCount

Function Reference

_GUICtrlListViewGetSubItemsCount

Retrieve the number of columns

#Include <GuiListView.au3>
_GUICtrlListViewGetSubItemsCount ( $h_listview )

Parameters

$h_listview control id/control hWnd

Return Value

Number of columns

Remarks

None.

Related

_GUICtrlListViewGetItemText, _GUICtrlListViewDeleteColumn, _GUICtrlListViewHideColumn

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $msg, $Status, $Btn_count
GUICreate("ListView Get SubItems Count", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER))
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
$Btn_count = GUICtrlCreateButton("Count SubItems", 150, 210, 90, 30)
$Btn_Exit = GUICtrlCreateButton("Exit", 150, 260, 90, 30)
$Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_count
GUICtrlSetData($Status, "SubItems: " & _GUICtrlListViewGetSubItemsCount($listview))
EndSelect
WEnd
Exit


Function _GUICtrlListViewGetTopIndex

Function Reference

_GUICtrlListViewGetTopIndex

Retrieves the index of the topmost visible item when in list or report view

#Include <GuiListView.au3>
_GUICtrlListViewGetTopIndex ( $h_listview )

Parameters

$h_listview control id/control hWnd

Return Value

Returns the index of the item if successful

Remarks

None.

Related

_GUICtrlListViewGetItemText, _GUICtrlListViewGetItemTextArray

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_GetTop, $Btn_Exit, $msg, $Status
GUICreate("ListView Get Top Index", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
GUICtrlCreateListViewItem("line6|data6|more6", $listview)
GUICtrlCreateListViewItem("line7|data7|more7", $listview)
GUICtrlCreateListViewItem("line8|data8|more8", $listview)
GUICtrlCreateListViewItem("line9|data9|more9", $listview)
GUICtrlCreateListViewItem("line10|data10|more10", $listview)
GUICtrlCreateListViewItem("line11|data11|more11", $listview)
GUICtrlCreateListViewItem("line12|data12|more12", $listview)
$Btn_GetTop = GUICtrlCreateButton("Get Top Index", 150, 230, 90, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Status = GUICtrlCreateLabel("Remember items are zero-indexed", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_GetTop
GUICtrlSetData($Status, "Top Index: " & _GUICtrlListViewGetTopIndex($listview))
EndSelect
WEnd
Exit


Function _GUICtrlListViewGetUnicodeFormat

Function Reference

_GUICtrlListViewGetUnicodeFormat

Retrieves the UNICODE character format flag for the control

#Include <GuiListView.au3>
_GUICtrlListViewGetUnicodeFormat ( $h_listview )

Parameters

$h_listview control id/control hWnd

Return Value

If this value is nonzero, the control is using Unicode characters.
If this value is zero, the control is using ANSI characters.

Remarks

The Unicode format flag is used by Microsoft Windows NT systems
with version 4.71 of Comctl32.dll or later. This message is, thus,
supported by Windows 2000 and later, and by Windows NT 4 with Microsoft
Internet Explorer 4.0 or later. It is only useful on Windows 95 or Windows 98
systems with version 5.80 or later of Comctl32.dll.

This means that they must have Internet Explorer 5 or later installed.
Windows 95 and Windows 98 systems with earlier versions of Internet Explorer
ignore the Unicode format flag, and its value has no bearing on whether a control
supports Unicode. With these systems, you will instead need to test something that
requires Unicode support.

Related

None.

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $msg, $Status
GUICreate("ListView Get Unicode Format", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
$Btn_Exit = GUICtrlCreateButton("Exit", 160, 260, 70, 30)
$Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
If (_GUICtrlListViewGetUnicodeFormat ($listview)) Then
GUICtrlSetData($Status, "ListView is using Unicode Characters")
Else
GUICtrlSetData($Status, "ListView is using ANSI Characters")
EndIf

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
EndSelect
WEnd
Exit


Function _GUICtrlListViewHideColumn

Function Reference

_GUICtrlListViewHideColumn

Hides the column "sets column width to zero"

#Include <GuiListView.au3>
_GUICtrlListViewHideColumn ( $h_listview, $i_col )

Parameters

$h_listview | control id/control hWnd
$i_col | column to hide (set width to zero)

Return Value

Returns TRUE if successful, or FALSE otherwise

Remarks

None.

Related

_GUICtrlListViewSetColumnWidth, _GUICtrlListViewGetColumnWidth

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_HideCol, $Btn_Exit, $msg, $Input_col, $Status, $Btn_ShowCol
GUICreate("ListView Hide Column Sets Column Width to Zero", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
GUICtrlCreateLabel("Enter Column # to Hide:", 90, 190, 130, 20)
$Input_col = GUICtrlCreateInput("", 220, 190, 80, 20, $ES_NUMBER)
GUICtrlSetLimit($Input_col, 1)
$Btn_HideCol = GUICtrlCreateButton("Hide Column", 75, 230, 90, 40)
$Btn_ShowCol = GUICtrlCreateButton("Show Column", 200, 230, 90, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Status = GUICtrlCreateLabel("Remember columns are zero-indexed", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_HideCol
If (StringLen(GUICtrlRead($Input_col)) > 0) Then
If (_GUICtrlListViewHideColumn ($listview, Int(GUICtrlRead($Input_col)))) Then
GUICtrlSetData($Status, 'Hide column: ' & GUICtrlRead($Input_col) & ' Successful')
Else
GUICtrlSetData($Status, 'Failed to Hide column: ' & GUICtrlRead($Input_col))
EndIf
Else
GUICtrlSetData($Status, 'Must enter a column to hide')
EndIf
Case $msg = $Btn_ShowCol
If (StringLen(GUICtrlRead($Input_col)) > 0) Then
If (_GUICtrlListViewSetColumnWidth ($listview, Int(GUICtrlRead($Input_col)), $LVSCW_AUTOSIZE)) Then
GUICtrlSetData($Status, 'Show column: ' & GUICtrlRead($Input_col) & ' Successful')
Else
GUICtrlSetData($Status, 'Failed to Show column: ' & GUICtrlRead($Input_col))
EndIf
Else
GUICtrlSetData($Status, 'Must enter a column to show')
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlListViewInsertColumn

Function Reference

_GUICtrlListViewInsertColumn

Inserts a column into a list-view control

#Include <GuiListView.au3>
_GUICtrlListViewInsertColumn ( $h_listview, $i_col, $s_text [, $i_justification=0 [, $i_width=25 ]] )

Parameters

$h_listview | control id/control hWnd
$i_col | Zero based index of column position to insert
$s_text | Header Text for column
$i_justification | Optional: type of justification for column
$i_width | Optional: width of the new column (default = 25)

Return Value

Returns TRUE if successful, or FALSE otherwise
if error then $LV_ERR is returned

Remarks

$i_justification
0 = Left (default)
1 = Right
2 = Center

Related

_GUICtrlListViewDeleteColumn, _GUICtrlListViewHideColumn

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

opt('MustDeclareVars', 1)
Dim $listview, $Btn_InsertCol, $Btn_Exit, $msg, $Input_col, $Status
GUICreate("ListView Insert Column", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
GUICtrlCreateLabel("Enter Column # to Insert:", 90, 190, 130, 20)
$Input_col = GUICtrlCreateInput("", 220, 190, 80, 20, $ES_NUMBER)
GUICtrlSetLimit($Input_col, 1)
$Btn_InsertCol = GUICtrlCreateButton("Insert Column", 150, 230, 90, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Status = GUICtrlCreateLabel("Remember columns are zero-indexed", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_InsertCol
If (StringLen(GUICtrlRead($Input_col)) > 0) Then
If (_GUICtrlListViewInsertColumn ($listview, Int(GUICtrlRead($Input_col)), "test", 0, 40)) Then
GUICtrlSetData($Status, 'Insert column: ' & GUICtrlRead($Input_col) & ' Successful')
Else
GUICtrlSetData($Status, 'Failed to Insert column: ' & GUICtrlRead($Input_col))
EndIf
Else
GUICtrlSetData($Status, 'Must enter a column to insert')
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlListViewInsertItem

Function Reference

_GUICtrlListViewInsertItem

Inserts a new item in a list-view control.

#Include <GuiListView.au3>
_GUICtrlListViewInsertItem ( $h_listview, $i_index, $s_text )

Parameters

$h_listview | control id/control hWnd
$i_index | Zero based index of position to insert. If -1 the item is append to the end.
$s_text | text for the new item

Return Value

Returns the index of the new item if successful, or $LV_ERR otherwise

Remarks

$s_text is "|" delimited text

Related

_GUICtrlListViewDeleteItem, _GUICtrlListViewDeleteItemsSelected

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

;~ Const $LVS_SORTDESCENDING = 0x0020
opt('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $msg, $Status, $Btn_Insert, $ret, $Input_Index
GUICreate("ListView Insert Item", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
_GUICtrlListViewSetColumnWidth ($listview, 0, 75)
_GUICtrlListViewSetColumnWidth ($listview, 1, 75)
_GUICtrlListViewSetColumnWidth ($listview, 2, 75)
GUICtrlCreateLabel("Enter Item # to Insert To:", 90, 190, 130, 20)
$Input_Index = GUICtrlCreateInput("", 220, 190, 80, 20, $ES_NUMBER)
$Btn_Insert = GUICtrlCreateButton("Insert Item", 150, 230, 90, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_Insert
If (StringLen(GUICtrlRead($Input_Index)) > 0) Then
$ret = _GUICtrlListViewInsertItem ($listview, Int(GUICtrlRead($Input_Index)), "test|1|2")
If ($ret <> $LV_ERR) Then
GUICtrlSetData($Status, 'Inserted Item at: ' & $ret)
Else
GUICtrlSetData($Status, 'Failed to Insert Item')
EndIf
Else
GUICtrlSetData($Status, 'Must enter a Item Index to insert')
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlListViewJustifyColumn

Function Reference

_GUICtrlListViewJustifyColumn

Set Justification of a column for a list-view control

#Include <GuiListView.au3>
_GUICtrlListViewJustifyColumn ( $h_listview, $i_col [, $i_justification=0 ] )

Parameters

$h_listview | control id/control hWnd
$i_col | Zero based index of column Justify
$i_justification | Optional: type of justification for column

Return Value

Returns TRUE if successful, or FALSE otherwise
if error then $LV_ERR is returned

Remarks

$i_justification
0 = Left (default)
1 = Right
2 = Center

Related

None.

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

opt('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $msg, $Status, $hList

;================================================================
; Example 1 - Justify Column using AutoIt Control
;================================================================
GUICreate("ListView Justify Column", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
$Status = GUICtrlCreateLabel("Remember columns are zero-indexed", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
If (_GUICtrlListViewJustifyColumn ($listview, 1, 2)) Then
GUICtrlSetData($Status, 'Justify column: 2 Successful')
Else
GUICtrlSetData($Status, 'Failed to Justify column: 2')
EndIf
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
_GUICtrlListViewSetColumnWidth ($listview, 0, 75)
_GUICtrlListViewSetColumnWidth ($listview, 1, 75)
_GUICtrlListViewSetColumnWidth ($listview, 2, 75)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
EndSelect
WEnd
GUIDelete()

;================================================================
; Example 2 - Justify Column using System Control
;================================================================
Run("explorer.exe /root, ,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")
WinWaitActive("My Computer")
$hList = ControlGetHandle("My Computer", "", "SysListView321")
_GUICtrlListViewJustifyColumn($hList, 1, 2)


Function _GUICtrlListViewScroll

Function Reference

_GUICtrlListViewScroll

Scrolls the content of a list-view control

#Include <GuiListView.au3>
_GUICtrlListViewScroll ( $h_listview, $i_dx, $i_dy )

Parameters

$h_listview | control id/control hWnd
$i_dx | Value of type int that specifies the amount of horizontal scrolling in pixels. If the list-view control is in list-view, this value specifies the number of columns to scroll
$i_dy | Value of type int that specifies the amount of vertical scrolling in pixels

Return Value

Returns TRUE if successful, or FALSE otherwise

Remarks

When the list-view control is in report view, the control can
only be scrolled vertically in whole line increments.

Therefore, the $i_dy parameter will be rounded to the nearest number
of pixels that form a whole line increment.

For example, if the height of a line is 16 pixels and 8 is passed for $i_dy,
the list will be scrolled by 16 pixels (1 line). If 7 is passed for $i_dy,
the list will be scrolled 0 pixels (0 lines).

Related

None.

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_TestScroll, $Btn_Exit, $msg, $Status, $i
GUICreate("ListView Scroll", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
GUICtrlCreateListViewItem("line6|data6|more6", $listview)
GUICtrlCreateListViewItem("line7|data7|more7", $listview)
GUICtrlCreateListViewItem("line8|data8|more8", $listview)
GUICtrlCreateListViewItem("line9|data9|more9", $listview)
GUICtrlCreateListViewItem("line10|data10|more10", $listview)
GUICtrlCreateListViewItem("line11|data11|more11", $listview)
GUICtrlCreateListViewItem("line12|data12|more12", $listview)
$Btn_TestScroll = GUICtrlCreateButton("Scroll Test", 150, 230, 90, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Status = GUICtrlCreateLabel("Remember items are zero-indexed", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_TestScroll
For $i = 10 To 50 Step 10
_GUICtrlListViewScroll($listview,0,$i)
Sleep( 500 )
_GUICtrlListViewScroll($listview,0,$i - ($i * 2))
Sleep( 500 )
Next
EndSelect
WEnd
Exit


Function _GUICtrlListViewSetCheckState

Function Reference

_GUICtrlListViewSetCheckState

Sets the checked state of a list-view control item

#Include <GuiListView.au3>
_GUICtrlListViewSetCheckState ( $h_listview, $i_index [, $i_check = 1 ] )

Parameters

$h_listview | control id/control hWnd
$i_index | Zero-based index of the item
$i_check | Optional: value to set checked state to (1 = checked, 0 = not checked)

Return Value

Returns TRUE if successful, or FALSE otherwise
If error then $LV_ERR is returned

Remarks

Requires $LVS_EX_CHECKBOXES to be used in extended style when creating listview
$i_index = -1 sets all items
$i_check = 1 (default)

Related

_GUICtrlListViewGetCheckedState

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

opt('MustDeclareVars', 1)
Dim $listview, $Btn_Set, $Btn_SetAll, $Btn_Exit, $msg, $Status, $ret
GUICreate("ListView Set Check State", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_CHECKBOXES, $LVS_EX_CHECKBOXES)
GUICtrlCreateListViewItem("index 0|data1|more1", $listview)
GUICtrlCreateListViewItem("index 1|data2|more2", $listview)
GUICtrlCreateListViewItem("index 2|data3|more3", $listview)
GUICtrlCreateListViewItem("index 3|data4|more4", $listview)
GUICtrlCreateListViewItem("index 4|data5|more5", $listview)
_GUICtrlListViewSetColumnWidth ($listview, 0, 100)
$Btn_Set = GUICtrlCreateButton("Set Index 2", 150, 200, 90, 25)
$Btn_SetAll = GUICtrlCreateButton("Set All", 150, 230, 90, 25)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
Local $check = 1
Local $checkall = 1
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_SetAll
Local $ret = _GUICtrlListViewSetCheckState($listview, -1, $checkall)
$checkall = Not $checkall
If ($ret == $LV_ERR) Then
MsgBox(0, "Error", "Error setting Check state")
EndIf
Case $msg = $Btn_Set
Local $ret = _GUICtrlListViewSetCheckState($listview, 2, $check)
$check = Not $check
If ($ret == $LV_ERR) Then
MsgBox(0, "Error", "Error setting Check state")
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlListViewSetColumnHeaderText

Function Reference

_GUICtrlListViewSetColumnHeaderText

Change the text of a column header for a list-view control

#Include <GuiListView.au3>
_GUICtrlListViewSetColumnHeaderText ( $h_listview, $i_col, $s_text )

Parameters

$h_listview | control id/control hWnd
$i_col | Zero based index of column Justify
$s_text | New text for column header

Return Value

Returns TRUE if successful, or FALSE otherwise
if error then $LV_ERR is returned

Remarks

None.

Related

None.

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>
#Include <GuiStatusBar.au3>

Opt('MustDeclareVars', 1)
Local $listview, $Btn_Exit, $msg, $Status, $GUI, $hList
Local $a_PartsRightEdge[2] = [175, -1]
Local $a_PartsText[2] = ["", ""]

;================================================================
; Example 1 - Set Column Header Text in AutoIt Control
;================================================================
$GUI = GUICreate("ListView Set Column Header Text", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
$Status = _GuiCtrlStatusBarCreate ($GUI, $a_PartsRightEdge, $a_PartsText)

If (_GUICtrlListViewJustifyColumn ($listview, 1, 2)) Then
_GuiCtrlStatusBarSetText ($Status, "Justify column: 2 Successful", 1)
Else
_GuiCtrlStatusBarSetText ($Status, "Failed to Justify column: 2", 1)
EndIf
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
_GUICtrlListViewSetColumnWidth ($listview, 0, 75)
_GUICtrlListViewSetColumnWidth ($listview, 1, 75)
_GUICtrlListViewSetColumnWidth ($listview, 2, 75)
If _GUICtrlListViewSetColumnHeaderText($listview, 1, "new text") Then
_GuiCtrlStatusBarSetText ($Status, "Set Header Text: Successful", 0)
Else
_GuiCtrlStatusBarSetText ($Status, "Failed to Set Header Text", 0)
EndIf
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
EndSelect
WEnd
GUIDelete()

;================================================================
; Example 2 - Set Column Header Text in System Control
;================================================================
Run("explorer.exe /root, ,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}")
WinWaitActive("My Computer")
$hList = ControlGetHandle("My Computer", "", "SysListView321")
_GUICtrlListViewSetColumnHeaderText($hList, 1, "Testing")


Function _GUICtrlListViewSetColumnOrder

Function Reference

_GUICtrlListViewSetColumnOrder

Sets the left-to-right order of columns in a list-view control.

#Include <GuiListView.au3>
_GUICtrlListViewSetColumnOrder ( $h_listview, $s_order )

Parameters

$h_listbox | control id/control hWnd
$s_order | "|" delimited column order i.e. "2|0|3|1"

Return Value

Returns nonzero if successful, or zero otherwise.
If an error occurs, the return value is $LV_ERR.

Remarks

Columns are Zero-based

Related

_GUICtrlListViewGetColumnOrder

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

opt('MustDeclareVars', 1)

Dim $listview, $button, $msg, $i, $ret

GUICreate("ListView Set Column Order", 392, 254)
$listview = GUICtrlCreateListView("col1|col2|col3|col4", 100, 10, 200, 100, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER))
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_HEADERDRAGDROP, $LVS_EX_HEADERDRAGDROP)
$button = GUICtrlCreateButton("Set Order", 150, 120, 90, 30)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$ret = _GUICtrlListViewSetColumnOrder($listview, "3|2|0|1")
EndSelect
WEnd


Function _GUICtrlListViewSetColumnWidth

Function Reference

_GUICtrlListViewSetColumnWidth

Changes the width of a column

#Include <GuiListView.au3>
_GUICtrlListViewSetColumnWidth ( $h_listview, $i_col, $i_width )

Parameters

$h_listview | control id/control hWnd
$i_col | Zero-based index of a valid column. For list-view mode, this parameter must be set to zero
$i_width | New width of the column, in pixels.

Return Value

Returns TRUE if successful, or FALSE otherwise.

Remarks

For report-view mode, the following special values are supported:

$LVSCW_AUTOSIZE | Automatically sizes the column.
$LVSCW_AUTOSIZE_USEHEADER | Automatically sizes the column to fit the header text. If you use this value with the last column, its width is set to fill the remaining width of the list-view control

Related

_GUICtrlListViewGetColumnWidth, _GUICtrlListViewHideColumn

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_SetWidth, $Btn_Exit, $msg, $Input_width, $Status
GUICreate("ListView Sets Column Width", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
GUICtrlCreateLabel("Enter Column Width:", 90, 190, 130, 20)
$Input_width = GUICtrlCreateInput("", 220, 190, 80, 20, $ES_NUMBER)
GUICtrlSetLimit($Input_width, 3)
$Btn_SetWidth = GUICtrlCreateButton("Set Width", 75, 230, 90, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_SetWidth
If (StringLen(GUICtrlRead($Input_width)) > 0) Then
If (_GUICtrlListViewSetColumnWidth ($listview, 1, Int(GUICtrlRead($Input_width)))) Then
GUICtrlSetData($Status, 'Set Column Width Successful')
Else
GUICtrlSetData($Status, 'Failed to set column width')
EndIf
Else
GUICtrlSetData($Status, 'Must enter a width')
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlListViewSetHotItem

Function Reference

_GUICtrlListViewSetHotItem

Sets the hot item for a list-view control

#Include <GuiListView.au3>
_GUICtrlListViewSetHotItem ( $h_listview, $i_index )

Parameters

$h_listview | control id/control hWnd
$i_index | Zero-based index of the item to be set as the hot item

Return Value

Returns the index of the item that was previously hot
$LV_ERR is returned if no item previously hot

Remarks

None.

Related

_GUICtrlListViewGetHotItem, _GUICtrlListViewGetHoverTime, _GUICtrlListViewSetHoverTime

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $msg, $Status, $Btn_set
GUICreate("ListView Set Hot Item", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER))
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_TRACKSELECT, $LVS_EX_TRACKSELECT)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
$Btn_set = GUICtrlCreateButton("Set index 2", 75, 260, 70, 30)
$Btn_Exit = GUICtrlCreateButton("Exit", 200, 260, 70, 30)
$Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_set
_GUICtrlListViewSetHotItem($listview,2)
GUICtrlSetData($Status, "Hot Item: " & _GUICtrlListViewGetHotItem ($listview))
EndSelect
WEnd
Exit


Function _GUICtrlListViewSetHoverTime

Function Reference

_GUICtrlListViewSetHoverTime

Sets the amount of time which the mouse cursor must hover over an item before it is selected

#Include <GuiListView.au3>
_GUICtrlListViewSetHoverTime ( $h_listview, $i_time )

Parameters

$h_listview | control id/control hWnd
$i_time | The new amount of time, in milliseconds

Return Value

Returns the previous hover time

Remarks

If $i_time value is -1, then the hover time is set to the default hover time
The hover time only affects list-view controls that have the
$LVS_EX_TRACKSELECT, $LVS_EX_ONECLICKACTIVATE, or
$LVS_EX_TWOCLICKACTIVATE extended list-view style

Related

_GUICtrlListViewGetHoverTime, _GUICtrlListViewGetHotItem

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

Opt ('MustDeclareVars', 1)
Dim $listview, $Btn_SetHoverTime, $Btn_Exit, $msg, $Input, $Status, $ret, $current
GUICreate("ListView Sets Hover Time", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER))
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_TRACKSELECT, $LVS_EX_TRACKSELECT)
GUICtrlCreateListViewItem("line1|data1|more1", $listview)
GUICtrlCreateListViewItem("line2|data2|more2", $listview)
GUICtrlCreateListViewItem("line3|data3|more3", $listview)
GUICtrlCreateListViewItem("line4|data4|more4", $listview)
GUICtrlCreateListViewItem("line5|data5|more5", $listview)
GUICtrlCreateLabel("Enter Hover Time:", 90, 190, 130, 20)
$Input = GUICtrlCreateInput("", 220, 190, 80, 20, $ES_NUMBER)
GUICtrlSetLimit($Input, 3)
$Btn_SetHoverTime = GUICtrlCreateButton("Set Hover Time", 75, 230, 90, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$current = _GUICtrlListViewGetHoverTime ($listview)
$Status = GUICtrlCreateLabel("Hover Time:" & $current, 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
While 1
$msg = GUIGetMsg()
If ($current <> _GUICtrlListViewGetHoverTime ($listview)) Then
GUICtrlSetData($Status, "Hover Time:" & _GUICtrlListViewGetHoverTime ($listview))
$current = _GUICtrlListViewGetHoverTime ($listview)
EndIf
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_SetHoverTime
If (StringLen(GUICtrlRead($Input)) > 0) Then
$ret = _GUICtrlListViewSetHoverTime ($listview, Int(GUICtrlRead($Input)))
EndIf
EndSelect
WEnd
Exit


Function _GUICtrlListViewSetItemCount

Function Reference

_GUICtrlListViewSetItemCount

Causes the list-view control to allocate memory for the specified number of items.

#Include <GuiListView.au3>
_GUICtrlListViewSetItemCount ( $h_listview, $i_items )

Parameters

$h_listbox | control id/control hWnd
$i_items | Number of items that the list-view control will ultimately contain.

Return Value

Returns nonzero if successful, or zero otherwise.
If an error occurs, the return value is $LV_ERR.

Remarks

Causes the control to allocate its internal data structures for the specified number of items.
This prevents the control from having to allocate the data structures every time an item is added.

Related

None.

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

opt('MustDeclareVars', 1)

Dim $listview, $button, $msg, $i, $ret, $s_item

GUICreate("ListView Set Item Count", 392, 254)
$listview = GUICtrlCreateListView("col1|col2|col3|col4", 100, 10, 200, 100, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER))
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_HEADERDRAGDROP, $LVS_EX_HEADERDRAGDROP)
$button = GUICtrlCreateButton("Add Items", 150, 120, 90, 30)
_GUICtrlListViewSetItemCount($listview, 20)
GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
For $i = 0 To 19
$s_item = $i & "|" & $i & "|" & $i & "|" & $i
GUICtrlCreateListViewItem($s_item, $listview)
Next
EndSelect
WEnd


Function _GUICtrlListViewSetItemSelState

Function Reference

_GUICtrlListViewSetItemSelState

Sets the Item Selected/UnSelected

#Include <GuiListView.au3>
_GUICtrlListViewSetItemSelState ( $h_listview, $i_index [, $i_selected = 1 [, $i_focused = 0 ]] )

Parameters

$h_listview | control id/control hWnd
$i_index | Zero-based index of the item
$i_selected | Optional: set the state of the item (1 = selected, 0 = not selected)
$i_focused | Optional: set the state of the item (1 = focused, 0 = not focused)

Return Value

1 if successful, 0 otherwise
If error then $LV_ERR is returned

Remarks

$i_index = -1 sets all items for MultiSelect ListView
$i_selected = 1 (default)

Related

_GUICtrlListViewGetSelectedCount, _GUICtrlListViewGetSelectedIndices

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

opt('MustDeclareVars', 1)
Dim $listview, $Btn_Set, $Btn_Exit, $msg, $Status, $ret, $Btn_UnSet
GUICreate("ListView Set Item Sel State", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER))
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("index 0|data1|more1", $listview)
GUICtrlCreateListViewItem("index 1|data2|more2", $listview)
GUICtrlCreateListViewItem("index 2|data3|more3", $listview)
GUICtrlCreateListViewItem("index 3|data4|more4", $listview)
GUICtrlCreateListViewItem("index 4|data5|more5", $listview)
_GUICtrlListViewSetColumnWidth ($listview, 0, 100)
$Btn_Set = GUICtrlCreateButton("Set Index 2 Selected", 150, 200, 120, 40)
$Btn_UnSet = GUICtrlCreateButton("UnSet Index 2 Selected", 150, 250, 120, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))
_GUICtrlListViewSetItemSelState ($listview, -1)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_Set
_GUICtrlListViewSetItemSelState ($listview, 2)
Case $msg = $Btn_UnSet
_GUICtrlListViewSetItemSelState ($listview, 2, 0)
EndSelect
WEnd
Exit


Function _GUICtrlListViewSetItemText

Function Reference

_GUICtrlListViewSetItemText

Changes the text of a list-view item or subitem.

#Include <GuiListView.au3>
_GUICtrlListViewSetItemText ( $h_listview, $i_index, $i_subitem, $s_text )

Parameters

$h_listview | control id/control hWnd
$i_index | Zero-based index of the item
$i_subitem | Index of the subitem, or it can be zero to set the item label.
$s_text | String containing the new text

Return Value

Success: | Returns 1
Failure: | Returns 0 or if error $LV_ERR

Remarks

None.

Related

_GUICtrlListViewGetItemText

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

opt('MustDeclareVars', 1)
Dim $listview, $Btn_SetItem0, $Btn_Exit, $msg, $Status, $ret, $Btn_SetSub1
GUICreate("ListView Set Item Text", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER))
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("index 0|data1|more1", $listview)
GUICtrlCreateListViewItem("index 1|data2|more2", $listview)
GUICtrlCreateListViewItem("index 2|data3|more3", $listview)
GUICtrlCreateListViewItem("index 3|data4|more4", $listview)
GUICtrlCreateListViewItem("index 4|data5|more5", $listview)
_GUICtrlListViewSetColumnWidth ($listview, 0, 100)
$Btn_SetItem0 = GUICtrlCreateButton("Set 2 Item", 150, 200, 120, 40)
$Btn_SetSub1 = GUICtrlCreateButton("Set 2 SubItem", 150, 250, 120, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)
$Status = GUICtrlCreateLabel("", 0, 302, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_SetItem0
_GUICtrlListViewSetItemText ($listview, 2, 0, "Testing")
Case $msg = $Btn_SetSub1
_GUICtrlListViewSetItemText ($listview, 2, 1, "Sub")
EndSelect
WEnd
Exit


Function _GUICtrlListViewSort

Function Reference

_GUICtrlListViewSort

Sorts a list-view control.

#Include <GuiListView.au3>
_GUICtrlListViewSort ( $h_listview, ByRef $v_descending, $i_sortcol )

Parameters

$h_listview | control id/control hWnd
$v_descending | boolean value, can be a single value or array
$i_sortcol | column to sort on

Return Value

None

Remarks

Utilizes the _ArraySort User Defined Function

Related

None.

Example

#include <GuiConstants.au3>
#include <GuiListView.au3>

opt('MustDeclareVars', 1)
Dim $listview, $Btn_Exit, $msg, $Status, $Btn_Insert, $ret, $Input_Index
GUICreate("ListView Sort", 392, 322)

$listview = GUICtrlCreateListView("col1|col2|col3", 40, 30, 310, 149)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT)
GUICtrlCreateListViewItem("line4|5|more_a", $listview)
GUICtrlCreateListViewItem("line5|4.50 |more_c", $listview)
GUICtrlCreateListViewItem("line5|4.0 |more_c", $listview)
GUICtrlCreateListViewItem("line3|23|more_e", $listview)
GUICtrlCreateListViewItem("line2|0.34560 |more_d", $listview)
GUICtrlCreateListViewItem("line1|1.0 |more_b", $listview)
GUICtrlCreateListViewItem("line1|0.1 |more_b", $listview)
GUICtrlCreateListViewItem("line1|10|more_b", $listview)
_GUICtrlListViewSetColumnWidth ($listview, 0, 75)
_GUICtrlListViewSetColumnWidth ($listview, 1, 75)
_GUICtrlListViewSetColumnWidth ($listview, 2, 75)
$Btn_Exit = GUICtrlCreateButton("Exit", 300, 260, 70, 30)

GUISetState()

Dim $B_DESCENDING[_GUICtrlListViewGetSubItemsCount ($listview) ]

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $listview
; sort the list by the column header clicked on
_GUICtrlListViewSort($listview, $B_DESCENDING, GUICtrlGetState($listview))
EndSelect
WEnd

Exit


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: GuiMonthCal Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_GUICtrlMonthCalGet1stDOW | Retrieves the first day of the week for a month calendar control.
_GUICtrlMonthCalGetColor | Retrieves the color for a given portion of a month calendar control.
_GUICtrlMonthCalGetDelta | Retrieves the scroll rate for a month calendar control.
_GUICtrlMonthCalGetMaxSelCount | Retrieves the maximum date range that can be selected in a month calendar control.
_GUICtrlMonthCalGetMaxTodayWidth | Retrieves the maximum width of the "today" string in a month calendar control.
_GUICtrlMonthCalGetMinReqRECT | Retrieves the minimum size required to display a full month in a month calendar control.
_GUICtrlMonthCalSet1stDOW | Sets the first day of the week for a month calendar control.
_GUICtrlMonthCalSetColor | Sets the color for a given portion of a month calendar control.
_GUICtrlMonthCalSetDelta | Sets the scroll rate for a month calendar control.
_GUICtrlMonthCalSetMaxSelCount | Sets the maximum number of days that can be selected in a month calendar control.


Function _GUICtrlMonthCalGet1stDOW

Function Reference

_GUICtrlMonthCalGet1stDOW

Retrieves the first day of the week for a month calendar control.

#Include <GuiMonthCal.au3>
_GUICtrlMonthCalGet1stDOW ( $h_monthcal )

Parameters

$h_monthcal control id/control hWnd

Return Value

String of 1st Day Of Week

Remarks

None.

Related

_GUICtrlMonthCalSet1stDOW

Example

#include <GUIConstants.au3>
#include <date.au3>
#include <GuiMonthCal.au3>

opt('MustDeclareVars', 1)

Dim $Date

GUICreate( "Get First Day Of Week", 210, 190)

$Date = GUICtrlCreateMonthCal (_NowCalcDate(), 10, 10)
MsgBox(0, "First Day Of Week", _GUICtrlMonthCalGet1stDOW ($Date), 10)


Function _GUICtrlMonthCalGetColor

Function Reference

_GUICtrlMonthCalGetColor

Retrieves the color for a given portion of a month calendar control.

#Include <GuiMonthCal.au3>
_GUICtrlMonthCalGetColor ( $h_monthcal, $i_color )

Parameters

$h_monthcal | control id/control hWnd
$i_color | Value of type int specifying which month calendar color to retrieve.

Return Value

Array containing the color

Remarks

$i_color this value can be one of the following:

$MCSC_BACKGROUND | Retrieve the background color displayed between months.
$MCSC_MONTHBK | Retrieve the background color displayed within the month.
$MCSC_TEXT | Retrieve the color used to display text within a month.
$MCSC_TITLEBK | Retrieve the background color displayed in the calendar's title.
$MCSC_TITLETEXT | Retrieve the color used to display text within the calendar's title.
$MCSC_TRAILINGTEXT | Retrieve the color used to display header day and trailing day text. Header and trailing days are the days from the previous and following months that appear on the current month calendar.

Array returned
$array[0] - contains the number returned
$array[1] - contains COLORREF rgbcolor
$array[2] - contains Hex BGR color
$array[3] - contains Hex RGB color

Related

_GUICtrlMonthCalSetColor

Example

#include <GUIConstants.au3>
#include <date.au3>
#include <GuiMonthCal.au3>

opt('MustDeclareVars', 1)

Dim $Date, $i, $a_colors

GUICreate( "Get Color", 210, 190)

$Date = GUICtrlCreateMonthCal (_NowCalcDate(), 10, 10)
GUISetState()

; 1 - COLORREF rgbcolor
; 2 - Hex BGR color
; 3 - Hex RGB color
$a_colors = _GUICtrlMonthCalGetColor ($Date, $MCSC_BACKGROUND)
For $i = 1 To $a_colors[0]
MsgBox(0, "Background color displayed between months.", $a_colors[$i])
Next

$a_colors = _GUICtrlMonthCalGetColor ($Date, $MCSC_MONTHBK)
For $i = 1 To $a_colors[0]
MsgBox(0, "Background color displayed within the month.", $a_colors[$i])
Next

$a_colors = _GUICtrlMonthCalGetColor ($Date, $MCSC_TEXT)
For $i = 1 To $a_colors[0]
MsgBox(0, "Color used to display text within a month.", $a_colors[$i])
Next

$a_colors = _GUICtrlMonthCalGetColor ($Date, $MCSC_TITLEBK)
For $i = 1 To $a_colors[0]
MsgBox(0, "Background color displayed in the calendar's title.", $a_colors[$i])
Next

$a_colors = _GUICtrlMonthCalGetColor ($Date, $MCSC_TITLETEXT)
For $i = 1 To $a_colors[0]
MsgBox(0, "Color used to display text within the calendar's title.", $a_colors[$i])
Next

$a_colors = _GUICtrlMonthCalGetColor ($Date, $MCSC_TRAILINGTEXT)
For $i = 1 To $a_colors[0]
MsgBox(0, "Color used to display header day and trailing day text.", $a_colors[$i])
Next


Function _GUICtrlMonthCalGetDelta

Function Reference

_GUICtrlMonthCalGetDelta

Retrieves the scroll rate for a month calendar control.

#Include <GuiMonthCal.au3>
_GUICtrlMonthCalGetDelta ( $h_monthcal )

Parameters

$h_monthcal control id/control hWnd

Return Value

If the month delta was previously set using the _GUICtrlMonthCalSetDelta,
returns an INT value that represents the month calendar's current scroll rate.
If the month delta was not previously set using the _GUICtrlMonthCalSetDelta,
or the month delta was reset to the default, returns an INT value that
represents the current number of months visible.

Remarks

None.

Related

_GUICtrlMonthCalSetDelta

Example

#include <GUIConstants.au3>
#include <date.au3>
#include <GuiMonthCal.au3>

opt('MustDeclareVars', 1)

Dim $Date, $Btn_Exit, $Status, $msg

GUICreate( "Get Delta", 392, 254)

$Date = GUICtrlCreateMonthCal (_NowCalcDate(), 90, 10, 200, 160)

$Status = GUICtrlCreateLabel("", 0, 234, 392, 20, BitOR($SS_SUNKEN, $SS_CENTER))

$Btn_Exit = GUICtrlCreateButton("Exit", 150, 180, 90, 30)

GUISetState()
GUICtrlSetData($Status, "Month Delta: " & _GUICtrlMonthCalGetDelta ($Date))
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
EndSelect
WEnd


Function _GUICtrlMonthCalGetMaxSelCount

Function Reference

_GUICtrlMonthCalGetMaxSelCount

Retrieves the maximum date range that can be selected in a month calendar control.

#Include <GuiMonthCal.au3>
_GUICtrlMonthCalGetMaxSelCount ( $h_monthcal )

Parameters

$h_monthcal control id/control hWnd

Return Value

Returns an INT value that represents the total number of days that can be selected for the control.

Remarks

None.

Related

_GUICtrlMonthCalSetMaxSelCount

Example

#include <GUIConstants.au3>
#include <date.au3>
#include <GuiMonthCal.au3>

opt('MustDeclareVars', 1)

Dim $Date

GUICreate( "Get Max Sel Count", 210, 190)

$Date = GUICtrlCreateMonthCal (_NowCalcDate(), 10, 10)
GUISetState()

MsgBox(0, "Total number of days that can be selected for the control.", _GUICtrlMonthCalGetMaxSelCount ($Date), 10)


Function _GUICtrlMonthCalGetMaxTodayWidth

Function Reference

_GUICtrlMonthCalGetMaxTodayWidth

Retrieves the maximum width of the "today" string in a month calendar control.

#Include <GuiMonthCal.au3>
_GUICtrlMonthCalGetMaxTodayWidth ( $h_monthcal )

Parameters

$h_monthcal control id/control hWnd

Return Value

Returns the width of the "today" string, in pixels.

Remarks

None.

Related

None.

Example

#include <GUIConstants.au3>
#include <date.au3>
#include <GuiMonthCal.au3>

opt('MustDeclareVars', 1)

Dim $Date

GUICreate( "Get Max Today Width", 210, 190)

$Date = GUICtrlCreateMonthCal (_NowCalcDate(), 10, 10)
GUISetState()

MsgBox(0, 'Maximum width of the "today" string in a month calendar control.', _GUICtrlMonthCalGetMaxTodayWidth ($Date), 10)


Function _GUICtrlMonthCalGetMinReqRECT

Function Reference

_GUICtrlMonthCalGetMinReqRECT

Retrieves the minimum size required to display a full month in a month calendar control.

#Include <GuiMonthCal.au3>
_GUICtrlMonthCalGetMinReqRECT ( $h_monthcal )

Parameters

$h_monthcal control id/control hWnd

Return Value

Array containing the RECT, first element ($array[0]) contains the number of elements
if error -1 is returned

Remarks

The minimum required window size for a month calendar control depends on the currently selected font,
control styles, system metrics, and regional settings.

Related

None.

Example

#include <GUIConstants.au3>
#include <date.au3>
#include <GuiMonthCal.au3>

opt('MustDeclareVars', 1)

Dim $Date, $s_rect, $label_rect, $Btn_GETRECT, $Btn_Exit, $msg

GUICreate("Month Calender Get Min Required RECT", 400, 250)

$Date = GUICtrlCreateMonthCal (_NowCalcDate(), 10, 10)

$s_rect = "Left:" & @LF & "Top:" & @LF & "Right:" & @LF & "Bottom:"
$label_rect = GUICtrlCreateLabel($s_rect, 270, 40, 100, 55, $SS_SUNKEN)

$Btn_GETRECT = GUICtrlCreateButton("Get Rect", 270, 120, 90, 40)
$Btn_Exit = GUICtrlCreateButton("Exit", 150, 180, 90, 30)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Btn_GETRECT
Local $rect_array = _GUICtrlMonthCalGetMinReqRECT ($Date)
If (IsArray($rect_array)) Then
$s_rect = "Left:" & $rect_array[1] & @LF & "Top:" & $rect_array[2] & @LF & "Right:" & $rect_array[3] & @LF & "Bottom:" & $rect_array[4]
GUICtrlSetData($label_rect, $s_rect)
EndIf
EndSelect
WEnd


Function _GUICtrlMonthCalSet1stDOW

Function Reference

_GUICtrlMonthCalSet1stDOW

Sets the first day of the week for a month calendar control.

#Include <GuiMonthCal.au3>
_GUICtrlMonthCalSet1stDOW ( $h_monthcal, $s_day )

Parameters

$h_monthcal | control id/control hWnd
$s_day | Value representing which day is to be set as the first day of the week.

Return Value

The previous first day of the week.
if error -1 is returned

Remarks

$s_day:
0 or "Monday"
1 or "Tuesday"
2 or "Wednesday"
3 or "Thursday"
4 or "Friday"
5 or "Saturday"
6 or "Sunday"

Related

_GUICtrlMonthCalGet1stDOW

Example

#include <GUIConstants.au3>
#include <date.au3>
#include <GuiMonthCal.au3>

opt('MustDeclareVars', 1)

Dim $Date, $Btn_Exit, $Combo, $msg

GUICreate( "Set First Day Of Week", 450, 254)

$Date = GUICtrlCreateMonthCal (_NowCalcDate(), 10, 10)

$Btn_Exit = GUICtrlCreateButton("Exit", 180, 180, 90, 30)

$Combo = GUICtrlCreateCombo("", 220, 10, 100, 21, $CBS_DROPDOWNLIST)
GUICtrlSetData($Combo, "Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday", "Sunday")

GUISetState()

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Combo
_GUICtrlMonthCalSet1stDOW ($Date, GUICtrlRead($Combo))
EndSelect
WEnd


Function _GUICtrlMonthCalSetColor

Function Reference

_GUICtrlMonthCalSetColor

Sets the color for a given portion of a month calendar control.

#Include <GuiMonthCal.au3>
_GUICtrlMonthCalSetColor ( $h_monthcal, $i_color, $i_colorref [, $i_refType = 0 ] )

Parameters

$h_monthcal | control id/control hWnd
$i_color | Value of type int specifying which month calendar color to set.
$i_colorref | Value that represents the color that will be set for the specified area of the month calendar.
$i_refType | Optional: Type of value used for $i_colorref

Return Value

Success: | Returns an array of the previous color setting for the specified portion of the month calendar control
Failure: | Returns -1

Remarks

$i_color this value can be one of the following:

$MCSC_BACKGROUND | Set the background color displayed between months.
$MCSC_MONTHBK | Set the background color displayed within the month.
$MCSC_TEXT | Set the color used to display text within a month.
$MCSC_TITLEBK | Set the background color displayed in the calendar's title.
$MCSC_TITLETEXT | Set the color used to display text within the calendar's title.
$MCSC_TRAILINGTEXT | Set the color used to display header day and trailing day text. Header and trailing days are the days from the previous and following months that appear on the current month calendar.

$i_refType = 0 $i_colorref is COLORREF rgbcolor (default)
$i_refType = 1 $i_colorref is Hex BGR color
$i_refType = 0 $i_colorref is Hex RGB color

Value returned:
array[0] = number of elements
array[1] = COLORREF rbgcolor
array[2] = Hex BGR color
array[3] = Hex RGB color

Related

_GUICtrlMonthCalGetColor

Example

#include <GUIConstants.au3>
#include <date.au3>
#include <GuiMonthCal.au3>

opt('MustDeclareVars', 1)

Dim $Date, $i, $a_colors, $Btn_Exit, $msg

GUICreate( "Set Color", 450, 254)

$Date = GUICtrlCreateMonthCal (_NowCalcDate(), 10, 10, 430, 160, 0, 0)

$Btn_Exit = GUICtrlCreateButton("Exit", 180, 180, 90, 30)

GUISetState()

; returns array of previous color if setcolor is successful
; 1 - COLORREF rgbcolor
; 2 - Hex BGR color
; 3 - Hex RGB color

; Set the background color displayed between months.
$a_colors = _GUICtrlMonthCalSetColor ($Date, $MCSC_BACKGROUND, 255)

;Set the background color displayed within the month.
$a_colors = _GUICtrlMonthCalSetColor ($Date, $MCSC_MONTHBK, 0xff0000, 1)

;Set the color used to display text within a month.
$a_colors = _GUICtrlMonthCalSetColor ($Date, $MCSC_TEXT, 0x00ffff, 1)

;Set the background color displayed in the calendar's title.
$a_colors = _GUICtrlMonthCalSetColor ($Date, $MCSC_TITLEBK, 0x000000, 2)

;Set the color used to display text within the calendar's title.
$a_colors = _GUICtrlMonthCalSetColor ($Date, $MCSC_TITLETEXT, 0xC0C0C0, 2)

;Set the color used to display header day and trailing day text.
$a_colors = _GUICtrlMonthCalSetColor ($Date, $MCSC_TRAILINGTEXT, 0xe6e6fa, 2)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
EndSelect
WEnd


Function _GUICtrlMonthCalSetDelta

Function Reference

_GUICtrlMonthCalSetDelta

Sets the scroll rate for a month calendar control.

#Include <GuiMonthCal.au3>
_GUICtrlMonthCalSetDelta ( $h_monthcal, $i_delta )

Parameters

$h_monthcal | control id/control hWnd
$i_delta | Value representing the number of months to be set as the control's scroll rate.

Return Value

Returns an INT value that represents the previous scroll rate.

Remarks

$i_delta
If this value is zero, the month delta is reset to the default,
which is the number of months displayed in the control.

Related

_GUICtrlMonthCalGetDelta

Example

#include <GUIConstants.au3>
#include <date.au3>
#include <GuiMonthCal.au3>

opt('MustDeclareVars', 1)

Dim $Date, $Btn_Exit, $Combo, $msg

GUICreate( "Set Delta", 450, 254)

$Date = GUICtrlCreateMonthCal (_NowCalcDate(), 10, 10, 190, 155, $MCS_MULTISELECT)

$Btn_Exit = GUICtrlCreateButton("Exit", 180, 180, 90, 30)

$Combo = GUICtrlCreateCombo("", 220, 10, 100, 21, $CBS_DROPDOWNLIST)
GUICtrlSetData($Combo, "1|2|3|4|5|6|7|8|9|10|11|12", "1")

GUISetState()

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Combo
_GUICtrlMonthCalSetDelta ($Date, Int(GUICtrlRead($Combo)))
EndSelect
WEnd


Function _GUICtrlMonthCalSetMaxSelCount

Function Reference

_GUICtrlMonthCalSetMaxSelCount

Sets the maximum number of days that can be selected in a month calendar control.

#Include <GuiMonthCal.au3>
_GUICtrlMonthCalSetMaxSelCount ( $h_monthcal, $i_maxsel )

Parameters

$h_monthcal | control id/control hWnd
$i_maxsel | Value of type int that will be set to represent the maximum number of days that can be selected.

Return Value

Returns nonzero if successful, or zero otherwise.

Remarks

This will fail if applied to a month calendar control that does not use the $MCS_MULTISELECT style.

Related

_GUICtrlMonthCalGetMaxSelCount

Example

#include <GUIConstants.au3>
#include <date.au3>
#include <GuiMonthCal.au3>

opt('MustDeclareVars', 1)

Dim $Date, $Btn_Exit, $Combo, $msg, $Status

GUICreate( "Set Max Sel Count", 450, 254)

$Date = GUICtrlCreateMonthCal (_NowCalcDate(), 10, 10, 190, 155, $MCS_MULTISELECT)
$Status = GUICtrlCreateLabel("", 0, 234, 450, 20, BitOR($SS_SUNKEN, $SS_CENTER))

$Btn_Exit = GUICtrlCreateButton("Exit", 180, 180, 90, 30)

$Combo = GUICtrlCreateCombo("", 220, 10, 100, 21, $CBS_DROPDOWNLIST)
GUICtrlSetData($Combo, "1|2|3|4|5|6|7|8|9|10|11|12", "1")

GUISetState()

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit
ExitLoop
Case $msg = $Combo
If (_GUICtrlMonthCalSetMaxSelCount ($Date, GUICtrlRead($Combo))) Then
GUICtrlSetData($Status, "Successful")
Else
GUICtrlSetData($Status, "Failed")
EndIf
EndSelect
WEnd


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: GuiSlider Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_GUICtrlSliderClearTics | Removes the current tick marks from a slider.
_GUICtrlSliderGetLineSize | Retrieves the number of logical positions the slider moves.
_GUICtrlSliderGetNumTics | Retrieves the number of tick marks from a slider.
_GUICtrlSliderGetPageSize | Retrieves the number of logical positions the slider moves.
_GUICtrlSliderGetPos | Retrieves the logical position the slider.
_GUICtrlSliderGetRangeMax | Retrieves the maximum position for the slider.
_GUICtrlSliderGetRangeMin | Retrieves the minimum position for the slider.
_GUICtrlSliderSetLineSize | Sets the number of logical positions the slider moves.
_GUICtrlSliderSetPageSize | Sets the number of logical positions the slider moves.
_GUICtrlSliderSetPos | Sets the current logical position of the slider.
_GUICtrlSliderSetTicFreq | Sets the interval frequency for tick marks in a slider.


Function _GUICtrlSliderClearTics

Function Reference

_GUICtrlSliderClearTics

Removes the current tick marks from a slider.

#Include <GuiSlider.au3>
_GUICtrlSliderClearTics ( $h_slider )

Parameters

$h_slider handle of the control

Return Value

None.

Remarks

This does not remove the first and last tick marks, which are created automatically.

Related

None.

Example

#include <GUIConstants.au3>
#include <GuiSlider.au3>

opt('MustDeclareVars', 1)

Dim $Gui_Slider, $slider1, $button, $msg, $h_slider

$Gui_Slider = GUICreate("Slider Clear Tics", 220, 100, 100, 200)
GUISetBkColor(0x00E0FFFF) ; will change background color

$slider1 = GUICtrlCreateSlider(10, 10, 200, 20)
GUICtrlSetLimit(-1, 200, 0) ; change min/max value
$button = GUICtrlCreateButton("Clear Tics", 75, 70, 70, 20)
GUISetState()
GUICtrlSetData($slider1, 45) ; set cursor
$h_slider = ControlGetHandle($Gui_Slider, "", "msctls_trackbar321")
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
_GUICtrlSliderClearTics ($h_slider)
EndSelect
WEnd


Function _GUICtrlSliderGetLineSize

Function Reference

_GUICtrlSliderGetLineSize

Retrieves the number of logical positions the slider moves.

#Include <GuiSlider.au3>
_GUICtrlSliderGetLineSize ( $h_slider )

Parameters

$h_slider handle of the control

Return Value

Returns value that specifies the line size for the slider.

Remarks

Retrieves the number of logical positions the slider moves in response to keyboard input from the arrow keys.
The logical positions are the integer increments in the slider's range of minimum to maximum slider positions.

Related

_GUICtrlSliderSetLineSize

Example

#include <GUIConstants.au3>
#include <GuiSlider.au3>

opt('MustDeclareVars', 1)

Dim $Gui_Slider, $slider1, $msg, $h_slider, $Status

$Gui_Slider = GUICreate("Slider Get Line Size", 220, 100, 100, 200)
GUISetBkColor(0x00E0FFFF) ; will change background color

$slider1 = GUICtrlCreateSlider(10, 10, 200, 20)
GUICtrlSetLimit(-1, 200, 0) ; change min/max value
GUISetState()
GUICtrlSetData($slider1, 45) ; set cursor
$h_slider = ControlGetHandle($Gui_Slider, "", "msctls_trackbar321")
$Status = GUICtrlCreateLabel("Line Size: " & _GUICtrlSliderGetLineSize ($h_slider), 0, 80, 220, 20, BitOR($SS_SUNKEN, $SS_CENTER))
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd


Function _GUICtrlSliderGetNumTics

Function Reference

_GUICtrlSliderGetNumTics

Retrieves the number of tick marks from a slider.

#Include <GuiSlider.au3>
_GUICtrlSliderGetNumTics ( $h_slider )

Parameters

$h_slider handle of the control

Return Value

If no tick flag is set, it returns 2 for the beginning and ending ticks.
If $TBS_NOTICKS is set, it returns zero.
Otherwise, it takes the difference between the range minimum and maximum, divides by the tick frequency, and adds 2.

Remarks

None.

Related

_GUICtrlSliderSetTicFreq

Example

#include <GUIConstants.au3>
#include <GuiSlider.au3>

opt('MustDeclareVars', 1)

Dim $Gui_Slider, $slider1, $msg, $h_slider, $Status

$Gui_Slider = GUICreate("Slider Get Num Tics", 220, 100, 100, 200)
GUISetBkColor(0x00E0FFFF) ; will change background color

$slider1 = GUICtrlCreateSlider(10, 10, 200, 20)
GUICtrlSetLimit(-1, 200, 0) ; change min/max value
GUISetState()
GUICtrlSetData($slider1, 45) ; set cursor
$h_slider = ControlGetHandle($Gui_Slider, "", "msctls_trackbar321")
$Status = GUICtrlCreateLabel("Num of Tics: " & _GUICtrlSliderGetNumTics ($h_slider), 0, 80, 220, 20, BitOR($SS_SUNKEN, $SS_CENTER))
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd


Function _GUICtrlSliderGetPageSize

Function Reference

_GUICtrlSliderGetPageSize

Retrieves the number of logical positions the slider moves.

#Include <GuiSlider.au3>
_GUICtrlSliderGetPageSize ( $h_slider )

Parameters

$h_slider handle of the control

Return Value

Returns a value that specifies the page size for the slider.

Remarks

Retrieves the number of logical positions the slider moves in response to keyboard input,
or mouse input, such as clicks in the sliders's channel.
The logical positions are the integer increments in the slider's range of minimum to maximum slider positions.

Related

_GUICtrlSliderSetPageSize

Example

#include <GUIConstants.au3>
#include <GuiSlider.au3>

opt('MustDeclareVars', 1)

Dim $Gui_Slider, $slider1, $msg, $h_slider, $Status

$Gui_Slider = GUICreate("Slider Get Page Size", 220, 100, 100, 200)
GUISetBkColor(0x00E0FFFF) ; will change background color

$slider1 = GUICtrlCreateSlider(10, 10, 200, 20)
GUICtrlSetLimit(-1, 200, 0) ; change min/max value
GUISetState()
GUICtrlSetData($slider1, 45) ; set cursor
$h_slider = ControlGetHandle($Gui_Slider, "", "msctls_trackbar321")
$Status = GUICtrlCreateLabel("Page Size: " & _GUICtrlSliderGetPageSize ($h_slider), 0, 80, 220, 20, BitOR($SS_SUNKEN, $SS_CENTER))
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd


Function _GUICtrlSliderGetPos

Function Reference

_GUICtrlSliderGetPos

Retrieves the logical position the slider.

#Include <GuiSlider.au3>
_GUICtrlSliderGetPos ( $h_slider )

Parameters

$h_slider handle of the control

Return Value

Returns a value that specifies the logical position of the slider.

Remarks

None.

Related

_GUICtrlSliderSetPos

Example

#include <GUIConstants.au3>
#include <GuiSlider.au3>

opt('MustDeclareVars', 1)

Dim $Gui_Slider, $slider1, $button, $msg, $h_slider, $Status, $Pos = 0

$Gui_Slider = GUICreate("Slider Get Pos",220,100)
GUISetBkColor (0x00E0FFFF) ; will change background color

$slider1 = GUICtrlCreateSlider (10,10,200,20)
GUICtrlSetLimit(-1,200,0) ; change min/max value
$button = GUICtrlCreateButton ("Value?",75,50,70,20)
GUISetState()
GUICtrlSetData($slider1,45) ; set cursor
$h_slider = ControlGetHandle($Gui_Slider, "", "msctls_trackbar321")
$Status = GUICtrlCreateLabel("Pos: " & _GUICtrlSliderGetPos($h_slider), 0, 80, 220, 20, BitOR($SS_SUNKEN, $SS_CENTER))

While 1
$msg = GUIGetMsg ()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
GUICtrlSetData($Status,"Pos: " & _GUICtrlSliderGetPos($h_slider))
EndSelect
WEnd


Function _GUICtrlSliderGetRangeMax

Function Reference

_GUICtrlSliderGetRangeMax

Retrieves the maximum position for the slider.

#Include <GuiSlider.au3>
_GUICtrlSliderGetRangeMax ( $h_slider )

Parameters

$h_slider handle of the control

Return Value

Returns a value that specifies the maximum position in the slider's range of minimum to maximum slider positions.

Remarks

None.

Related

_GUICtrlSliderGetRangeMin

Example

#include <GUIConstants.au3>
#include <GuiSlider.au3>

opt('MustDeclareVars', 1)

Dim $Gui_Slider, $slider1, $msg, $h_slider, $Status

$Gui_Slider = GUICreate("Slider Get Range Max", 220, 100, 100, 200)
GUISetBkColor(0x00E0FFFF) ; will change background color

$slider1 = GUICtrlCreateSlider(10, 10, 200, 20)
GUICtrlSetLimit(-1, 220, 20) ; change min/max value
GUISetState()
GUICtrlSetData($slider1, 45) ; set cursor
$h_slider = ControlGetHandle($Gui_Slider, "", "msctls_trackbar321")
$Status = GUICtrlCreateLabel("Max: " & _GUICtrlSliderGetRangeMax ($h_slider), 0, 80, 220, 20, BitOR($SS_SUNKEN, $SS_CENTER))
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd


Function _GUICtrlSliderGetRangeMin

Function Reference

_GUICtrlSliderGetRangeMin

Retrieves the minimum position for the slider.

#Include <GuiSlider.au3>
_GUICtrlSliderGetRangeMin ( $h_slider )

Parameters

$h_slider handle of the control

Return Value

Returns a value that specifies the minimum position in the slider's range of minimum to maximum slider positions.

Remarks

None.

Related

_GUICtrlSliderGetRangeMax

Example

#include <GUIConstants.au3>
#include <GuiSlider.au3>

opt('MustDeclareVars', 1)

Dim $Gui_Slider, $slider1, $msg, $h_slider, $Status

$Gui_Slider = GUICreate("Slider Get Range Min", 220, 100, 100, 200)
GUISetBkColor(0x00E0FFFF) ; will change background color

$slider1 = GUICtrlCreateSlider(10, 10, 200, 20)
GUICtrlSetLimit(-1, 220, 20) ; change min/max value
GUISetState()
GUICtrlSetData($slider1, 45) ; set cursor
$h_slider = ControlGetHandle($Gui_Slider, "", "msctls_trackbar321")
$Status = GUICtrlCreateLabel("Min: " & _GUICtrlSliderGetRangeMin ($h_slider), 0, 80, 220, 20, BitOR($SS_SUNKEN, $SS_CENTER))
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd


Function _GUICtrlSliderSetLineSize

Function Reference

_GUICtrlSliderSetLineSize

Sets the number of logical positions the slider moves.

#Include <GuiSlider.au3>
_GUICtrlSliderSetLineSize ( $h_slider, $i_linesize )

Parameters

$h_slider | handle of the control
$i_linesize | New line size

Return Value

Returns a value that specifies the previous line size.

Remarks

Sets the number of logical positions the slider moves in response to keyboard input from the arrow keys.
The logical positions are the integer increments in the slider's range of minimum to maximum slider positions.

Related

_GUICtrlSliderGetLineSize

Example

#include <GUIConstants.au3>
#include <GuiSlider.au3>

opt('MustDeclareVars', 1)

Dim $Gui_Slider, $slider1, $button, $msg, $h_slider, $Status

$Gui_Slider = GUICreate("Slider Set Line Size", 220, 100, 100, 200)
GUISetBkColor(0x00E0FFFF) ; will change background color

$slider1 = GUICtrlCreateSlider(10, 10, 200, 20)
GUICtrlSetLimit(-1, 200, 0) ; change min/max value
$button = GUICtrlCreateButton("Set Line Size", 75, 55, 70, 20)
GUISetState()
GUICtrlSetData($slider1, 45) ; set cursor
$h_slider = ControlGetHandle($Gui_Slider, "", "msctls_trackbar321")
$Status = GUICtrlCreateLabel("Line Size: " & _GUICtrlSliderGetLineSize ($h_slider), 0, 80, 220, 20, BitOR($SS_SUNKEN, $SS_CENTER))
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
_GUICtrlSliderSetLineSize ($h_slider, 10)
GUICtrlSetData($Status, "Line Size: " & _GUICtrlSliderGetLineSize ($h_slider))
EndSelect
WEnd


Function _GUICtrlSliderSetPageSize

Function Reference

_GUICtrlSliderSetPageSize

Sets the number of logical positions the slider moves.

#Include <GuiSlider.au3>
_GUICtrlSliderSetPageSize ( $h_slider, $i_pagesize )

Parameters

$h_slider | handle of the control
$i_pagesize | New page size

Return Value

Returns a value that specifies the previous page size.

Remarks

Sets the number of logical positions the slider moves in response to keyboard input,
or mouse input, such as clicks in the slider's channel.
The logical positions are the integer increments in the slider's range of minimum to maximum slider positions.

Related

_GUICtrlSliderGetPageSize

Example

#include <GUIConstants.au3>
#include <GuiSlider.au3>

opt('MustDeclareVars', 1)

Dim $Gui_Slider, $slider1, $button, $msg, $h_slider, $Status

$Gui_Slider = GUICreate("Slider Set Page Size", 220, 100, 100, 200)
GUISetBkColor(0x00E0FFFF) ; will change background color

$slider1 = GUICtrlCreateSlider(10, 10, 200, 20)
GUICtrlSetLimit(-1, 200, 0) ; change min/max value
$button = GUICtrlCreateButton("Set Page Size", 75, 55, 75, 20)
GUISetState()
GUICtrlSetData($slider1, 45) ; set cursor
$h_slider = ControlGetHandle($Gui_Slider, "", "msctls_trackbar321")
$Status = GUICtrlCreateLabel("Page Size: " & _GUICtrlSliderGetPageSize ($h_slider), 0, 80, 220, 20, BitOR($SS_SUNKEN, $SS_CENTER))
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
_GUICtrlSliderSetPageSize ($h_slider, 10)
GUICtrlSetData($Status, "Page Size: " & _GUICtrlSliderGetPageSize ($h_slider))
EndSelect
WEnd


Function _GUICtrlSliderSetPos

Function Reference

_GUICtrlSliderSetPos

Sets the current logical position of the slider.

#Include <GuiSlider.au3>
_GUICtrlSliderSetPos ( $h_slider, $i_pos )

Parameters

$h_slider | handle of the control
$i_pos | New logical position of the slider

Return Value

None.

Remarks

None.

Related

None.

Example

#include <GUIConstants.au3>
#include <GuiSlider.au3>

opt('MustDeclareVars', 1)

Dim $Gui_Slider, $slider1, $button, $msg, $h_slider, $Status, $Pos = 0

$Gui_Slider = GUICreate("Slider Set Pos", 220, 100, 100, 200)
GUISetBkColor(0x00E0FFFF) ; will change background color

$slider1 = GUICtrlCreateSlider(10, 10, 200, 20)
GUICtrlSetLimit(-1, 200, 0) ; change min/max value
$button = GUICtrlCreateButton("Set Pos", 75, 55, 75, 20)
GUISetState()
GUICtrlSetData($slider1, 45) ; set cursor
$h_slider = ControlGetHandle($Gui_Slider, "", "msctls_trackbar321")
$Status = GUICtrlCreateLabel("Pos: " & GUICtrlRead($slider1), 0, 80, 220, 20, BitOR($SS_SUNKEN, $SS_CENTER))
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$Pos += 10
If $Pos > 200 Then
$Pos = 10
EndIf
_GUICtrlSliderSetPos ($h_slider, $Pos)
GUICtrlSetData($Status, "Pos: " & GUICtrlRead($slider1))
EndSelect
WEnd


Function _GUICtrlSliderSetTicFreq

Function Reference

_GUICtrlSliderSetTicFreq

Sets the interval frequency for tick marks in a slider.

#Include <GuiSlider.au3>
_GUICtrlSliderSetTicFreq ( $h_slider, $i_freq )

Parameters

$h_slider | handle of the control
$i_freq | Frequency of the tick marks

Return Value

None.

Remarks

The slider must have the $TBS_AUTOTICKS style to use this.

Related

_GUICtrlSliderGetNumTics

Example

#include <GUIConstants.au3>
#include <GuiSlider.au3>

opt('MustDeclareVars', 1)

Dim $Gui_Slider, $slider1, $button, $msg, $h_slider, $Status

$Gui_Slider = GUICreate("Slider Set Tic Freq", 220, 100, 100, 200)
GUISetBkColor(0x00E0FFFF) ; will change background color

$slider1 = GUICtrlCreateSlider(10, 10, 200, 20)
GUICtrlSetLimit(-1, 200, 0) ; change min/max value
$button = GUICtrlCreateButton("Set Freq", 75, 55, 70, 20)
GUISetState()
GUICtrlSetData($slider1, 45) ; set cursor
$h_slider = ControlGetHandle($Gui_Slider, "", "msctls_trackbar321")
$Status = GUICtrlCreateLabel("Num of Tics: " & _GUICtrlSliderGetNumTics ($h_slider), 0, 80, 220, 20, BitOR($SS_SUNKEN, $SS_CENTER))
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
_GUICtrlSliderSetTicFreq ($h_slider, 5)
GUICtrlSetData($Status, "Num of Tics: " & _GUICtrlSliderGetNumTics ($h_slider))
EndSelect
WEnd


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: GuiStatusBar Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_GUICtrlStatusBarCreate | Creates Statusbar
_GUICtrlStatusBarCreateProgress | Creates ProgressBar in Statusbar part
_GUICtrlStatusBarDelete | Deletes the StatusBar control
_GUICtrlStatusBarGetBorders | Retrieves the current widths of the horizontal and vertical borders of a status window.
_GUICtrlStatusBarGetIcon | Retrieves the icon for a part in a status bar.
_GUICtrlStatusBarGetParts | Retrieves a count of the parts in a status window.
_GUICtrlStatusBarGetRect | Retrieves the bounding rectangle of a part in a status window.
_GUICtrlStatusBarGetText | retrieves the text from the specified part of a status window.
_GUICtrlStatusBarGetTextLength | Retrieves the length, in characters, of the text from the specified part of a status window.
_GUICtrlStatusBarGetTip | Retrieves the ToolTip text for a part in a status bar.
_GUICtrlStatusBarGetUnicode | Retrieves the Unicode character format flag for the control.
_GUICtrlStatusBarIsSimple | Checks a status bar control to determine if it is in simple mode.
_GUICtrlStatusBarResize | Resize Statusbar.
_GUICtrlStatusBarSetBKColor | Sets the background color in a status bar.
_GUICtrlStatusBarSetIcon | Sets an Icon in the Panel.
_GUICtrlStatusBarSetMinHeight | Sets the minimum height of a status window's drawing area.
_GUICtrlStatusBarSetParts | Sets the number of parts in a status window and the coordinate of the right edge of each part.
_GUICtrlStatusBarSetSimple | Specifies whether a status window displays simple text or displays all window parts.
_GUICtrlStatusBarSetText | Sets the text in the specified part of a status window.
_GUICtrlStatusBarSetTip | Sets the ToolTip text for a part in a status bar.
_GUICtrlStatusBarSetUnicode | Sets the Unicode character format flag for the control.
_GUICtrlStatusBarShowHide | Show/Hide the StatusBar control


Function _GUICtrlStatusBarCreate

Function Reference

_GUICtrlStatusBarCreate

Creates Statusbar

#Include <GuiStatusBar.au3>
_GUICtrlStatusBarCreate ( $h_Gui, $a_PartWidth, $s_PartText [, $v_styles = "" ] )

Parameters

$h_Gui | Handle to parent window
$a_PartWidth | width of part or parts (for more than 1 part pass in zero based array)
$s_PartText | text of part or parts (for more than 1 part pass in zero based array)
$v_styles | styles to apply to the status bar (Optional) for multiple styles bitor them.

Return Value

Returns hWhnd if successful, or 0 with error set to 1 otherwise.

Remarks

In Microsoft Windows XP and earlier, the text for each part is limited to 127 characters.

Status text align: left/center/right

By default, text is left-aligned within the specified part of a status bar.
You can embed tab characters (@TAB) in the text to center or right-align it.
Text to the right of a single tab character is centered,
and text to the right of a second tab character is right-aligned.

Related

Example

opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

$gui = GUICreate("Status Bar Create", 500, -1, -1, -1, $WS_SIZEBOX)
$StatusBar1 = _GUICtrlStatusBarCreate ($gui, $a_PartsRightEdge, $a_PartsText)

GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_RESIZED
_GUICtrlStatusBarResize ($StatusBar1)
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case Else
;;;;;
EndSelect

WEnd


Function _GUICtrlStatusBarCreateProgress

Function Reference

_GUICtrlStatusBarCreateProgress

Creates ProgressBar in Statusbar part

#Include <GuiStatusBar.au3>
_GUICtrlStatusBarCreateProgress ( $h_StatusBar, $i_Part [, $v_styles = "" ] )

Parameters

$h_StatusBar | The Control Id
$i_Part | Optional: Part of the status bar to create the progress in (Default 0)
$v_styles | Optional: Styles to apply to the progress bar for multiple styles bitor them.

Return Value

Returns Control Id if successful, or if error is set to -1 and -1 is returned.

Remarks

Related

_GUICtrlStatusBarCreate, _GUICtrlStatusBarSetParts, _GUICtrlStatusBarGetText

Example

Opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

;~ DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) ; turn off XP themes

Local $gui, $StatusBar1, $msg, $ProgressBar1, $ProgressBar2, $iProgress = 0, $button
Local $i, $s, $m, $wait
Local $a_PartsRightEdge[4] = [100, 220, 360, -1]
Local $a_PartsText[4] = ["", "" ,"", ""]

$gui = GUICreate("Status Bar Create", 500, -1, -1, -1, $WS_SIZEBOX)
$button = GUICtrlCreateButton ("Start",75,70,70,20)
$StatusBar1 = _GUICtrlStatusBarCreate($gui, $a_PartsRightEdge, $a_PartsText)
$ProgressBar1 = _GUICtrlStatusBarCreateProgress($StatusBar1, 1, $PBS_SMOOTH)
$ProgressBar2 = _GUICtrlStatusBarCreateProgress($StatusBar1, 2)
GUICtrlSetColor($ProgressBar1,32250)
GUISetState(@SW_SHOW)

$wait = 20; wait 20ms for next progressstep
$s = 0; progressbar-saveposition

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_RESIZED
_GUICtrlStatusBarResize($StatusBar1)
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
GUICtrlSetData ($button,"Stop")
For $i = $s To 100

If GUICtrlRead($ProgressBar1) = 50 Then _GUICtrlStatusBarSetText($StatusBar1,"The half is done...")
If GUICtrlRead($ProgressBar2) = 50 Then _GUICtrlStatusBarSetText($StatusBar1,"The half is done...",3)
$m = GUIGetMsg ()

If $m = -3 Then ExitLoop

If $m = $button Then
GUICtrlSetData ($button,"Next")
$s = $i;save the current bar-position to $s
ExitLoop
Else
$s=0
GUICtrlSetData ($ProgressBar1,$i)
GUICtrlSetData ($ProgressBar2,$i)
Sleep($wait)
EndIf
Next
if $i >100 Then GUICtrlSetData ($button,"Start")

EndSelect

WEnd


Function _GUICtrlStatusBarDelete

Function Reference

_GUICtrlStatusBarDelete

Deletes the StatusBar control

#Include <GuiStatusBar.au3>
_GUICtrlStatusBarDelete ( hwnd )

Parameters

hwnd Handle to statusbar

Return Value

If the function succeeds, the return value is nonzero
If the function fails, the return value is zero

Remarks

None.

Related

_GUICtrlStatusBarCreate

Example

opt("MustDeclareVars", 1)

#include <GUIConstantsEx.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg, $btn_delete
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

$gui = GUICreate("Status Bar Delete", 500, -1, -1, -1, $WS_SIZEBOX)
$StatusBar1 = _GUICtrlStatusBarCreate ($gui, $a_PartsRightEdge, $a_PartsText)
$btn_delete = GUICtrlCreateButton("Delete StatusBar", 10, 10, 120, 25)
GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_RESIZED
_GUICtrlStatusBarResize ($StatusBar1)
Case $msg = $btn_delete
_GUICtrlStatusBarDelete($StatusBar1)
GUICtrlSetState($btn_delete, $GUI_DISABLE)
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case Else
;;;;;
EndSelect

WEnd


Function _GUICtrlStatusBarGetBorders

Function Reference

_GUICtrlStatusBarGetBorders

Retrieves the current widths of the horizontal and vertical borders of a status window.

#Include <GuiStatusBar.au3>
_GUICtrlStatusBarGetBorders ( $h_StatusBar )

Parameters

$h_StatusBar Handle to statusbar

Return Value

Returns zero based array
0 - width of the horizontal border
1 - width of the vertical border
2 - width of the border between rectangles
or zero otherwise.

Remarks

None.

Related

Example

Opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg
Local $a_PartsRightEdge[3] = [150, 300, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

;================================================================
; Example 1 - Using AutoIt Control
;================================================================
$gui = GUICreate("Status Bar Get Border Widths", 500, -1, -1, -1, $WS_SIZEBOX)
$StatusBar1 = _GUICtrlStatusBarCreate($gui, $a_PartsRightEdge, $a_PartsText)

Local $a_borders = _GUICtrlStatusBarGetBorders($StatusBar1)
If IsArray($a_borders) Then
_GUICtrlStatusBarSetText($StatusBar1, "horizontal border: " & $a_borders[0], 0)
_GUICtrlStatusBarSetText($StatusBar1, "vertical border: " & $a_borders[1], 1)
_GUICtrlStatusBarSetText($StatusBar1, "between rectangles: " & $a_borders[2], 2)
EndIf

GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_RESIZED
_GUICtrlStatusBarResize($StatusBar1)
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case Else
;;;;;
EndSelect

WEnd
GUIDelete()

;================================================================
; Example 2 - External Control
;================================================================
Opt("WinTitleMatchMode", 4)
Local $h_win = WinGetHandle("classname=SciTEWindow")
Local $h_status = ControlGetHandle($h_win, "", "msctls_statusbar321")
$a_borders = _GUICtrlStatusBarGetBorders($h_status)
ConsoleWrite("horizontal border: " & $a_borders[0] & @LF & _
"vertical border: " & $a_borders[1] & @LF & _
"between rectangles: " & $a_borders[2] & @LF)


Function _GUICtrlStatusBarGetIcon

Function Reference

_GUICtrlStatusBarGetIcon

Retrieves the icon for a part in a status bar.

#Include <GuiStatusBar.au3>
_GUICtrlStatusBarGetIcon ( $h_StatusBar [, $i_Part=0 ] )

Parameters

$h_StatusBar | The Control Id (will be converted to hWnd)
$i_Part | Optional: The part to hold the text (Default = 0)

Return Value

return hwnd or zero otherwise.

Remarks

None.

Related

_GUICtrlStatusBarSetIcon

Example

opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

$gui = GUICreate("Status Bar Get Icon", 500, -1, -1, -1, $WS_SIZEBOX)

$StatusBar1 = _GUICtrlStatusBarCreate ($gui, $a_PartsRightEdge, $a_PartsText)
_GUICtrlStatusBarSetIcon($StatusBar1, 1, "shell32.dll", 168)
_GUICtrlStatusBarSetIcon($StatusBar1, 0, "shell32.dll", 21)
_GUICtrlStatusBarSetIcon($StatusBar1, 2, "shell32.dll", 24)

_GUICtrlStatusBarSetText($StatusBar1, _GUICtrlStatusBarGetIcon($StatusBar1, 0), 0)
_GUICtrlStatusBarSetText($StatusBar1, _GUICtrlStatusBarGetIcon($StatusBar1, 1), 1)
_GUICtrlStatusBarSetText($StatusBar1, _GUICtrlStatusBarGetIcon($StatusBar1, 2), 2)

GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_RESIZED
_GUICtrlStatusBarResize ($StatusBar1)
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case Else
;;;;;
EndSelect

WEnd


Function _GUICtrlStatusBarGetParts

Function Reference

_GUICtrlStatusBarGetParts

Retrieves a count of the parts in a status window.

#Include <GuiStatusBar.au3>
_GUICtrlStatusBarGetParts ( $h_StatusBar )

Parameters

$h_StatusBar The Control Id (will be converted to hWnd if it isn't)

Return Value

Returns the number of parts in the window, otherwise zero.

Remarks

None.

Related

_GUICtrlStatusBarCreate

Example

opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg, $lbl_Parts
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

$gui = GUICreate("Status Bar Get Parts", 500, -1, -1, -1, $WS_SIZEBOX)
$StatusBar1 = _GUICtrlStatusBarCreate ($gui, $a_PartsRightEdge, $a_PartsText)
$lbl_Parts = GUICtrlCreateLabel("Number of Parts: " & _GUICtrlStatusBarGetParts($StatusBar1),10,10,100,25,$SS_SUNKEN )

GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_RESIZED
_GUICtrlStatusBarResize ($StatusBar1)
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case Else
;;;;;
EndSelect

WEnd


Function _GUICtrlStatusBarGetRect

Function Reference

_GUICtrlStatusBarGetRect

Retrieves the bounding rectangle of a part in a status window.

#Include <GuiStatusBar.au3>
_GUICtrlStatusBarGetRect ( $h_StatusBar [, $i_part = 0 ] )

Parameters

$h_StatusBar | Handle to statusbar
$i_part | zero based index of part to retrieve rectangle from (Default: 0)

Return Value

Returns zero based array
0 - Left
1 - Top
2 - Right
3 - Bottom
zero otherwise.

Remarks

None.

Related

Example

Opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg
Local $a_PartsRightEdge[4] = [100, 200, 350, -1]
Local $a_PartsText[4] = ["New Text", "More Text", "Even More Text", "Hey some more"]

;================================================================
; Example 1 - Using AutoIt Control
;================================================================
$gui = GUICreate("Status Bar Get Rect", 500, -1, -1, -1, $WS_SIZEBOX)
$StatusBar1 = _GUICtrlStatusBarCreate($gui, $a_PartsRightEdge, $a_PartsText)

For $x = 0 To 3
_GetRectInformation($StatusBar1, $x)
Next

GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_RESIZED
_GUICtrlStatusBarResize($StatusBar1)
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case Else
;;;;;
EndSelect

WEnd
GUIDelete()

;================================================================
; Example 2 - External Control
;================================================================
Opt("WinTitleMatchMode", 4)
Local $h_win = WinGetHandle("classname=SciTEWindow")
Local $h_status = ControlGetHandle($h_win, "", "msctls_statusbar321")
Local $v_rect = _GUICtrlStatusBarGetRect($h_status, 0)
ConsoleWrite("Left: " & $v_rect[0] & @LF & _
"Top: " & $v_rect[1] & @LF & _
"Right: " & $v_rect[2] & @LF & _
"Bottom: " & $v_rect[3] & @LF)

Func _GetRectInformation(ByRef $StatusBar1, ByRef $i_part)
Local $a_rect = _GUICtrlStatusBarGetRect($StatusBar1, $i_part)
If IsArray($a_rect) Then _GUICtrlStatusBarSetText($StatusBar1, $a_rect[0] & "," & $a_rect[1] & "," & $a_rect[2] & "," & $a_rect[3], $i_part)
EndFunc ;==>_GetRectInformation


Function _GUICtrlStatusBarGetText

Function Reference

_GUICtrlStatusBarGetText

retrieves the text from the specified part of a status window.

#Include <GuiStatusBar.au3>
_GUICtrlStatusBarGetText ( $h_StatusBar [, $i_Part=0 ] )

Parameters

$h_StatusBar | The Control Id (will be converted to hWnd if isn't)
$i_Part | Optional: The part (part) to retreive the text from (zero based) (Default = 0)

Return Value

Text from part

Remarks

None.

Related

_GUICtrlStatusBarCreate, _GUICtrlStatusBarSetText

Example

Opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg, $lbl_Info
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

;================================================================
; Example 1 - Using AutoIt Control
;================================================================
$gui = GUICreate("Status Bar Get Text", 500, -1, -1, -1, $WS_SIZEBOX)
$lbl_Info = GUICtrlCreateLabel("", 10, 10, 150, 50, $SS_SUNKEN)
$StatusBar1 = _GUICtrlStatusBarCreate($gui, $a_PartsRightEdge, $a_PartsText)

GUICtrlSetData($lbl_Info, "1st Part: " & _GUICtrlStatusBarGetText($StatusBar1, 0) & @LF & _
"2nd Part: " & _GUICtrlStatusBarGetText($StatusBar1, 1) & @LF & _
"3rd Part: " & _GUICtrlStatusBarGetText($StatusBar1, 2))

GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_RESIZED
_GUICtrlStatusBarResize($StatusBar1)
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case Else
;;;;;
EndSelect

WEnd

;================================================================
; Example 2 - External Control
;================================================================
Opt("WinTitleMatchMode", 4)
Local $h_win = WinGetHandle("classname=SciTEWindow")
Local $h_status = ControlGetHandle($h_win, "", "msctls_statusbar321")
Local $v_rect = _GUICtrlStatusBarGetText($h_status)
ConsoleWrite("Text: " & _GUICtrlStatusBarGetText($h_status) & @LF)


Function _GUICtrlStatusBarGetTextLength

Function Reference

_GUICtrlStatusBarGetTextLength

Retrieves the length, in characters, of the text from the specified part of a status window.

#Include <GuiStatusBar.au3>
_GUICtrlStatusBarGetTextLength ($h_StatusBar [, $i_Part = 0 ] )

Parameters

$h_StatusBar | The Control Id (will be converted to hWnd)
$i_Part | Nubmer of the part to retrieve length from (zero based) (Default: 0)

Return Value

Text Length

Remarks

None.

Related

_GUICtrlStatusBarCreate, _GUICtrlStatusBarSetText

Example

Opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg, $lbl_Info
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

;================================================================
; Example 1 - Using AutoIt Control
;================================================================
$gui = GUICreate("Status Bar Get Text Length", 500, -1, -1, -1, $WS_SIZEBOX)
$StatusBar1 = _GUICtrlStatusBarCreate($gui, $a_PartsRightEdge, $a_PartsText)
$lbl_Info = GUICtrlCreateLabel("Text Length of 3rd Part: " & _GUICtrlStatusBarGetTextLength($StatusBar1, 2), 10, 10, 150, 20)

GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_RESIZED
_GUICtrlStatusBarResize($StatusBar1)
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case Else
;;;;;
EndSelect

WEnd
GUIDelete()

;================================================================
; Example 2 - External Control
;================================================================
Opt("WinTitleMatchMode", 4)
Local $h_win = WinGetHandle("classname=SciTEWindow")
Local $h_status = ControlGetHandle($h_win, "", "msctls_statusbar321")
Local $v_rect = _GUICtrlStatusBarGetText($h_status)
ConsoleWrite("Text: " & _GUICtrlStatusBarGetTextLength($h_status) & @LF)


Function _GUICtrlStatusBarGetTip

Function Reference

_GUICtrlStatusBarGetTip

Retrieves the ToolTip text for a part in a status bar.

#Include <GuiStatusBar.au3>
_GUICtrlStatusBarGetTip ( $h_StatusBar [, $i_Part=0 ] )

Parameters

$h_StatusBar | The Control Id (will be converted to hWnd)
$i_Part | Optional: The part to retreive the text from (Default: 0)

Return Value

Tip Text, on error empty string and @error is set to 1

Remarks

The status bar must be created with the $SBT_TOOLTIPS style to enable ToolTips.

This ToolTip text is displayed in two situations:

When the corresponding pane in the status bar contains only an icon.
When the corresponding pane in the status bar contains text that is truncated due to the size of the pane.

Related

_GUICtrlStatusBarCreate, _GUICtrlStatusBarSetTip

Example

Opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg, $lbl_Info
Local $a_PartsRightEdge[3] = [100, 200, -1]
Local $a_PartsText[3] = ["New Text", "Tip works when only icon in part or text exceeds part", "Even More Text"]

;================================================================
; Example 1 - Using AutoIt Control
;================================================================
$gui = GUICreate("Status Bar Get Tip Text", 500, -1, -1, -1, $WS_SIZEBOX)

$StatusBar1 = _GUICtrlStatusBarCreate($gui, $a_PartsRightEdge, $a_PartsText, $SBT_TOOLTIPS)

_GUICtrlStatusBarSetIcon($StatusBar1, 1, "shell32.dll", 168)
_GUICtrlStatusBarSetIcon($StatusBar1, 0, "shell32.dll", 21)
_GUICtrlStatusBarSetIcon($StatusBar1, 2, "shell32.dll", 24)

_GUICtrlStatusBarSetTip($StatusBar1, 0, "Part 1")
_GUICtrlStatusBarSetTip($StatusBar1, 1, "Tip works when only icon in part or text exceeds part")
_GUICtrlStatusBarSetTip($StatusBar1, 2, "Part 3")

$lbl_Info = GUICtrlCreateLabel("Tip Text of 2nd Part: " & _GUICtrlStatusBarGetTip($StatusBar1, 1), 10, 10, 400, 20)

GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_RESIZED
_GUICtrlStatusBarResize($StatusBar1)
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case Else
;;;;;
EndSelect

WEnd
GUIDelete()

;================================================================
; Example 2 - External Control
;================================================================
Opt("WinTitleMatchMode", 4)
Local $h_win = WinGetHandle("classname=SciTEWindow")
Local $h_status = ControlGetHandle($h_win, "", "msctls_statusbar321")
ConsoleWrite("Tip Text: " & _GUICtrlStatusBarGetTip($h_status) & @LF)


Function _GUICtrlStatusBarGetUnicode

Function Reference

_GUICtrlStatusBarGetUnicode

Retrieves the Unicode character format flag for the control.

#Include <GuiStatusBar.au3>
_GUICtrlStatusBarGetUnicode ( $h_StatusBar )

Parameters

$h_StatusBar The Control Id (will be converted to hWnd)

Return Value

If this value is nonzero, the control is using Unicode characters.
If this value is zero, the control is using ANSI characters.

Remarks

None.

Related

_GUICtrlStatusBarSetUnicode

Example

Opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

;================================================================
; Example 1 - Using AutoIt Control
;================================================================
$gui = GUICreate("Status Bar Get Unicode", 500, -1, -1, -1, $WS_SIZEBOX)

$StatusBar1 = _GUICtrlStatusBarCreate($gui, $a_PartsRightEdge, $a_PartsText)

If _GUICtrlStatusBarGetUnicode($StatusBar1) Then
_GUICtrlStatusBarSetText($StatusBar1, "Using Unicode characters", 1)
Else
_GUICtrlStatusBarSetText($StatusBar1, "NOT using Unicode characters", 1)
EndIf

GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_RESIZED
_GUICtrlStatusBarResize($StatusBar1)
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case Else
;;;;;
EndSelect

WEnd
GUIDelete()

;================================================================
; Example 2 - External Control
;================================================================
Opt("WinTitleMatchMode", 4)
Local $h_win = WinGetHandle("classname=SciTEWindow")
Local $h_status = ControlGetHandle($h_win, "", "msctls_statusbar321")
If _GUICtrlStatusBarGetUnicode($h_status) Then
ConsoleWrite("Using Unicode characters" & @LF)
Else
ConsoleWrite("NOT using Unicode characters" & @LF)
EndIf


Function _GUICtrlStatusBarIsSimple

Function Reference

_GUICtrlStatusBarIsSimple

Checks a status bar control to determine if it is in simple mode.

#Include <GuiStatusBar.au3>
_GUICtrlStatusBarIsSimple ( $h_StatusBar )

Parameters

$h_StatusBar Handle to statusbar

Return Value

non zero if a simple statusbar, zero if not a simple statusbar

Remarks

None.

Related

_GUICtrlStatusBarCreate, _GUICtrlStatusBarSetSimple

Example

Opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg, $button
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

;================================================================
; Example 1 - Using AutoIt Control
;================================================================
$gui = GUICreate("Status Bar Is Simple", 500, -1, -1, -1, $WS_SIZEBOX)
$button = GUICtrlCreateButton("Toggle", 10, 10, 90, 25)
$StatusBar1 = _GUICtrlStatusBarCreate($gui, $a_PartsRightEdge, $a_PartsText)

GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_RESIZED
_GUICtrlStatusBarResize($StatusBar1)
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
If _GUICtrlStatusBarIsSimple($StatusBar1) Then
_GUICtrlStatusBarSetSimple($StatusBar1, False)
Else
_GUICtrlStatusBarSetSimple($StatusBar1)
_GUICtrlStatusBarSetText($StatusBar1, "simple mode", $SB_SIMPLEID)
_GUICtrlStatusBarResize($StatusBar1)
EndIf
EndSelect

WEnd
GUIDelete()

;================================================================
; Example 2 - External Control
;================================================================
Opt("WinTitleMatchMode", 4)
Local $h_win = WinGetHandle("classname=SciTEWindow")
Local $h_status = ControlGetHandle($h_win, "", "msctls_statusbar321")
If _GUICtrlStatusBarIsSimple($h_status) Then
ConsoleWrite("simple mode" & @LF)
Else
ConsoleWrite("NOT simple mode" & @LF)
EndIf


Function _GUICtrlStatusBarResize

Function Reference

_GUICtrlStatusBarResize

Resize Statusbar.

#Include <GuiStatusBar.au3>
_GUICtrlStatusBarResize ( $h_StatusBar )

Parameters

$h_StatusBar The Control Id (will be converted to hWnd)

Return Value

If the function succeeds, the return value is nonzero, otherwise zero.

Remarks

None.

Related

_GUICtrlStatusBarSetMinHeight

Example

Opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Global $StatusBar2

_Example_1()
_Example_2()

Func _Example_1()

Local $gui, $StatusBar1, $msg
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

$gui = GUICreate("Status Bar Resize", 500, -1, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SYSMENU, $WS_SIZEBOX, $WS_MAXIMIZEBOX))

$StatusBar1 = _GUICtrlStatusBarCreate($gui, $a_PartsRightEdge, $a_PartsText)

GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_RESIZED Or $msg = $GUI_EVENT_MINIMIZE Or $msg = $GUI_EVENT_MAXIMIZE Or $msg = $GUI_EVENT_RESTORE
_GUICtrlStatusBarResize($StatusBar1)
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case Else
;;;;;
EndSelect

WEnd
GUIDelete()
EndFunc ;==>_Example_1

Func _Example_2()
Local $gui, $msg
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

$gui = GUICreate("Status Bar Resize", 500, -1, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SYSMENU, $WS_SIZEBOX, $WS_MAXIMIZEBOX))

$StatusBar2 = _GUICtrlStatusBarCreate($gui, $a_PartsRightEdge, $a_PartsText)

;$WM_SIZE/$WM_SIZING are defined in GuiStatusBar.au3
GUIRegisterMsg($WM_SIZING, "WM_SIZING"); handle resize
GUIRegisterMsg($WM_SIZE, "WM_SIZING"); button maximize

GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case Else
;;;;;
EndSelect

WEnd
GUIDelete()
EndFunc ;==>_Example_2

Func WM_SIZING()
Return _GUICtrlStatusBarResize($StatusBar2)
EndFunc ;==>WM_SIZING


Function _GUICtrlStatusBarSetBKColor

Function Reference

_GUICtrlStatusBarSetBKColor

Sets the background color in a status bar.

#Include <GuiStatusBar.au3>
_GUICtrlStatusBarSetBKColor ( $h_StatusBar, $v_HexRGB )

Parameters

$h_StatusBar | Handle to statusbar
$v_HexRGB | Hex RGB color to set Status Bar background

Return Value

Returns the previous background color or zero upon failure

Remarks

None.

Related

None.

Example

Opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg, $old_color
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]
Local Const $Yellow = 0xffff00

;================================================================
; Example 1 - Using AutoIt Control
;================================================================
$gui = GUICreate("Status Bar Set Back Color", 500, -1, -1, -1, $WS_SIZEBOX)

$StatusBar1 = _GUICtrlStatusBarCreate($gui, $a_PartsRightEdge, $a_PartsText)
$old_color = _GUICtrlStatusBarSetBKColor($StatusBar1, $Yellow)

GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_RESIZED
_GUICtrlStatusBarResize($StatusBar1)
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case Else
;;;;;
EndSelect

WEnd
GUIDelete()

;================================================================
; Example 2 - External Control
;================================================================
Opt("WinTitleMatchMode", 4)
Local $h_win = WinGetHandle("classname=SciTEWindow")
Local $h_status = ControlGetHandle($h_win, "", "msctls_statusbar321")
Local $old_color = _GUICtrlStatusBarSetBKColor($h_status, $Yellow)
Sleep(5000)
_GUICtrlStatusBarSetBKColor($h_status, $old_color)


Function _GUICtrlStatusBarSetIcon

Function Reference

_GUICtrlStatusBarSetIcon

Sets an Icon in the Panel.

#Include <GuiStatusBar.au3>
_GUICtrlStatusBarSetIcon ( $h_StatusBar, $i_part, $szIconFile, $iconID )

Parameters

$h_StatusBar | Handle to statusbar
$i_part | Number of part to add icon too
$s_IconFile | file to extract icon from
$i_iconID | id of the icon

Return Value

Returns nonzero if successful, or zero otherwise.

Remarks

None.

Related

_GUICtrlStatusBarGetIcon

Example

Opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

;================================================================
; Example 1 - Using AutoIt Control
;================================================================
$gui = GUICreate("Status Bar Set Icon", 500, -1, -1, -1, $WS_SIZEBOX)
$StatusBar1 = _GUICtrlStatusBarCreate($gui, $a_PartsRightEdge, $a_PartsText)

_GUICtrlStatusBarSetIcon($StatusBar1, 1, "shell32.dll", 168)
_GUICtrlStatusBarSetIcon($StatusBar1, 0, "shell32.dll", 21)
_GUICtrlStatusBarSetIcon($StatusBar1, 2, "shell32.dll", 24)

GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_RESIZED
_GUICtrlStatusBarResize($StatusBar1)
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case Else
;;;;;
EndSelect

WEnd
GUIDelete()

;================================================================
; Example 2 - External Control
;================================================================
Opt("WinTitleMatchMode", 4)
Local $h_win = WinGetHandle("classname=SciTEWindow")
Local $h_status = ControlGetHandle($h_win, "", "msctls_statusbar321")
_GUICtrlStatusBarSetIcon($h_status, 0, "shell32.dll", 21)
Sleep(5000)
_GUICtrlStatusBarSetIcon($h_status, 0)


Function _GUICtrlStatusBarSetMinHeight

Function Reference

_GUICtrlStatusBarSetMinHeight

Sets the minimum height of a status window's drawing area.

#Include <GuiStatusBar.au3>
_GUICtrlStatusBarSetMinHeight ( $h_StatusBar, $i_MinHeight )

Parameters

$h_StatusBar | Handle to statusbar
$i_MinHeight | Minimum height, in pixels, of the window

Return Value

None.

Remarks

None.

Related

_GUICtrlStatusBarResize

Example

opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

$gui = GUICreate("Status Bar Set Min Height", 500, -1, -1, -1, $WS_SIZEBOX)

$StatusBar1 = _GUICtrlStatusBarCreate ($gui, $a_PartsRightEdge, $a_PartsText)
_GUICtrlStatusBarSetMinHeight($StatusBar1, 30)

GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_RESIZED
_GUICtrlStatusBarResize ($StatusBar1)
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case Else
;;;;;
EndSelect

WEnd


Function _GUICtrlStatusBarSetParts

Function Reference

_GUICtrlStatusBarSetParts

Sets the number of parts in a status window and the coordinate of the right edge of each part.

#Include <GuiStatusBar.au3>
_GUICtrlStatusBarSetParts ( $h_GUI, $h_StatusBar, $i_Parts [, $v_PartWidth = 100 ] )

Parameters

$h_GUI | Control Id of parent window
$h_StatusBar | The Control Id (will be converted to hWnd)
$i_Parts | Number of parts to create (Minium created will be 1)
$v_PartWidth | width of part(s) (Default: 100, can be an array of widths)

Return Value

None.

Remarks

None.

Related

_GUICtrlStatusBarCreate, _GUICtrlStatusBarGetParts

Example

Opt("MustDeclareVars", 1)
#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

;================================================================
; Example 1 - Using AutoIt Control
;================================================================
_Main()

Func _Main()
Local $a_PartsRightEdge[3] = [150, 300, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]
Local $a_PartsRightEdge2[2] = [100, -1]
Local $gui, $input, $Button_1, $Button_2, $Button_3, $Button_4, $StatusBar1, $msg
$gui = GUICreate("Status Bar - Parts", 500, -1, -1, -1, $WS_SIZEBOX)
$input = GUICtrlCreateInput("", 10, 10, 120, 20, $ES_NUMBER)
$Button_1 = GUICtrlCreateButton("<-- Create", 140, 10, 100)
$Button_2 = GUICtrlCreateButton("3 Parts", 10, 40, 100, 20)
$Button_3 = GUICtrlCreateButton("2 Parts", 10, 70, 100, 20)
$Button_4 = GUICtrlCreateButton("3 Parts", 10, 100, 100, 20)
$StatusBar1 = _GUICtrlStatusBarCreate($gui, $a_PartsRightEdge, $a_PartsText)
GUISetState(@SW_SHOW)
_GUICtrlStatusBarSetParts($gui, $StatusBar1, $a_PartsRightEdge2) ; force an error, param 2 can not be an array
If @error Then _GUICtrlStatusBarSetText($StatusBar1, "Error: " & @error, 0)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_RESIZED
_GUICtrlStatusBarResize($StatusBar1)
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Button_1
If StringLen(GUICtrlRead($input)) Then _GUICtrlStatusBarSetParts($gui, $StatusBar1, Number(GUICtrlRead($input)))
Case $msg = $Button_2
_GUICtrlStatusBarSetParts($gui, $StatusBar1, 3, $a_PartsRightEdge)
Case $msg = $Button_3
_GUICtrlStatusBarSetParts($gui, $StatusBar1, 5, $a_PartsRightEdge2) ; number of parts is larger than array, parts = size of array
Case $msg = $Button_4
_GUICtrlStatusBarSetParts($gui, $StatusBar1, -1, $a_PartsRightEdge) ; number of parts is smaller than array, parts = size of array
EndSelect
WEnd
GUIDelete()
EndFunc ;==>_Main

;================================================================
; Example 2 - External Control
;================================================================
_External()

Func _External()
Opt("WinTitleMatchMode", 4)
Local $h_win = WinGetHandle("classname=SciTEWindow")
Local $h_status = ControlGetHandle($h_win, "", "msctls_statusbar321")
_GUICtrlStatusBarSetParts($h_win, $h_status, 3)
Sleep(10000)
_GUICtrlStatusBarSetParts($h_win, $h_status, 1)
EndFunc ;==>_External


Function _GUICtrlStatusBarSetSimple

Function Reference

_GUICtrlStatusBarSetSimple

Specifies whether a status window displays simple text or displays all window parts.

#Include <GuiStatusBar.au3>
_GUICtrlStatusBarSetSimple ( $h_StatusBar [, $b_Simple = True ] )

Parameters

$h_StatusBar | Handle to statusbar
$b_Simple | Display type flag. If this parameter is TRUE, the window displays simple text. (Default) If it is FALSE, it displays multiple parts

Return Value

None.

Remarks

None.

Related

_GUICtrlStatusBarCreate, _GUICtrlStatusBarIsSimple

Example

Opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg, $button
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

;================================================================
; Example 1 - Using AutoIt Control
;================================================================
$gui = GUICreate("Status Bar Set Simple", 500, -1, -1, -1, $WS_SIZEBOX)
$button = GUICtrlCreateButton("Toggle", 10, 10, 90, 25)
$StatusBar1 = _GUICtrlStatusBarCreate($gui, $a_PartsRightEdge, $a_PartsText)

GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_RESIZED
_GUICtrlStatusBarResize($StatusBar1)
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
If _GUICtrlStatusBarIsSimple($StatusBar1) Then
_GUICtrlStatusBarSetSimple($StatusBar1, False)
Else
_GUICtrlStatusBarSetSimple($StatusBar1)
_GUICtrlStatusBarSetText($StatusBar1, "simple mode", $SB_SIMPLEID)
_GUICtrlStatusBarResize($StatusBar1)
EndIf
EndSelect

WEnd
GUIDelete()

;================================================================
; Example 2 - External Control
;================================================================
Opt("WinTitleMatchMode", 4)
Local $h_win = WinGetHandle("classname=SciTEWindow")
Local $h_status = ControlGetHandle($h_win, "", "msctls_statusbar321")
If _GUICtrlStatusBarIsSimple($h_status) Then
_GUICtrlStatusBarSetSimple($h_status, False)
Else
_GUICtrlStatusBarSetSimple($h_status)
Sleep(5000)
_GUICtrlStatusBarSetSimple($h_status, False)
;~ _GUICtrlStatusBarSetText ($StatusBar1, "simple mode", $SB_SIMPLEID)
;~ _GUICtrlStatusBarResize ($StatusBar1)
EndIf


Function _GUICtrlStatusBarSetText

Function Reference

_GUICtrlStatusBarSetText

Sets the text in the specified part of a status window.

#Include <GuiStatusBar.au3>
_GUICtrlStatusBarSetText ( $h_StatusBar [, $s_Data = "" [, $i_Part = 0 ]] )

Parameters

$h_StatusBar | The Control Id (will be converted to hWnd)
$s_Data | The text to display in the part
$i_Part | Optional: The part to hold the text (Default: 0)

Return Value

Returns TRUE if successful, or FALSE otherwise.

Remarks

In Microsoft Windows XP and earlier, the text for each part is limited to 127 characters.

Status text align: left/center/right

By default, text is left-aligned within the specified part of a status bar.
You can embed tab characters (@TAB) in the text to center or right-align it.
Text to the right of a single tab character is centered,
and text to the right of a second tab character is right-aligned.

Related

_GUICtrlStatusBarCreate, _GUICtrlStatusBarGetText

Example

Opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = [@TAB & @TAB & "New Text", "Left" & @TAB & "Center" & @TAB & "Right", "Even More Text"]

;================================================================
; Example 1 - Using AutoIt Control
;================================================================
$gui = GUICreate("Status Bar Set Text", 500, -1, -1, -1, $WS_SIZEBOX)

$StatusBar1 = _GUICtrlStatusBarCreate($gui, $a_PartsRightEdge, $a_PartsText)
_GUICtrlStatusBarSetText($StatusBar1, @TAB & "Text has been set", 1)

GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_RESIZED
_GUICtrlStatusBarResize($StatusBar1)
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case Else
;;;;;
EndSelect

WEnd
GUIDelete()

;================================================================
; Example 2 - External Control
;================================================================
Opt("WinTitleMatchMode", 4)
Local $h_win = WinGetHandle("classname=SciTEWindow")
Local $h_status = ControlGetHandle($h_win, "", "msctls_statusbar321")
Local $s_text = _GUICtrlStatusBarGetText($h_status)
_GUICtrlStatusBarSetText($h_status, "Text has been set")
Sleep(5000)
_GUICtrlStatusBarSetText($h_status, $s_text)


Function _GUICtrlStatusBarSetTip

Function Reference

_GUICtrlStatusBarSetTip

Sets the ToolTip text for a part in a status bar.

#Include <GuiStatusBar.au3>
_GUICtrlStatusBarSetTip ( $h_StatusBar, $i_part, $s_ToolTip )

Parameters

$h_StatusBar | Handle to statusbar
$i_part | Zero-based index of the part that will receive the ToolTip text
$s_ToolTip | new ToolTip text

Return Value

None.

Remarks

The status bar must be created with the $SBT_TOOLTIPS style to enable ToolTips.

This ToolTip text is displayed in two situations:

When the corresponding pane in the status bar contains only an icon.
When the corresponding pane in the status bar contains text that is truncated due to the size of the pane.

Related

_GUICtrlStatusBarCreate, _GUICtrlStatusBarGetTip

Example

Opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg
Local $a_PartsRightEdge[3] = [100, 200, -1]
Local $a_PartsText[3] = ["", "Force tip to be shown when text is more than fits in the box", "Even More Text"]

;================================================================
; Example 1 - Using AutoIt Control
;================================================================
$gui = GUICreate("Status Bar Set Tip", 500, -1, -1, -1, $WS_SIZEBOX)

$StatusBar1 = _GUICtrlStatusBarCreate($gui, $a_PartsRightEdge, $a_PartsText, $SBT_TOOLTIPS)
_GUICtrlStatusBarSetIcon($StatusBar1, 0, "shell32.dll", 21)
_GUICtrlStatusBarSetTip($StatusBar1, 0, "Tip works when only icon in part or text exceeds part")
_GUICtrlStatusBarSetTip($StatusBar1, 1, "Force tip to be shown when text is more than fits in the box")
_GUICtrlStatusBarSetTip($StatusBar1, 2, "Part 3")

GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_RESIZED
_GUICtrlStatusBarResize($StatusBar1)
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case Else
;;;;;
EndSelect

WEnd
GUIDelete()

;================================================================
; Example 2 - External Control
;================================================================
Opt("WinTitleMatchMode", 4)
Local $h_win = WinGetHandle("classname=SciTEWindow")
Local $h_status = ControlGetHandle($h_win, "", "msctls_statusbar321")
Local $s_text = _GUICtrlStatusBarGetText($h_status)
_GUICtrlStatusBarSetText($h_status, "Text has been set")
_GUICtrlStatusBarSetText($h_status, "")
_GUICtrlStatusBarSetIcon($h_status, 0, "shell32.dll", 21)
Sleep(10000)
_GUICtrlStatusBarSetIcon($h_status, 0)
_GUICtrlStatusBarSetText($h_status, $s_text)


Function _GUICtrlStatusBarSetUnicode

Function Reference

_GUICtrlStatusBarSetUnicode

Sets the Unicode character format flag for the control.

#Include <GuiStatusBar.au3>
_GUICtrlStatusBarSetUnicode ( $h_StatusBar [, $b_Unicode = True ] )

Parameters

$h_StatusBar | Handle to statusbar
$b_Unicode | Optional: Determines the character set that is used by the control. If this value is TRUE, the control will use Unicode characters. (Default) If this value is FALSE, the control will use ANSI characters.

Return Value

Returns the previous Unicode format flag for the control

Remarks

None.

Related

_GUICtrlStatusBarGetUnicode

Example

Opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

;================================================================
; Example 1 - Using AutoIt Control
;================================================================
$gui = GUICreate("Status Bar Set Unicode", 500, -1, -1, -1, $WS_SIZEBOX)

$StatusBar1 = _GUICtrlStatusBarCreate($gui, $a_PartsRightEdge, $a_PartsText)

_GUICtrlStatusBarSetUnicode($StatusBar1, False)
If _GUICtrlStatusBarGetUnicode($StatusBar1) Then
_GUICtrlStatusBarSetText($StatusBar1, "using Unicode characters", 1)
Else
_GUICtrlStatusBarSetText($StatusBar1, "NOT using Unicode characters", 1)
EndIf

GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_RESIZED
_GUICtrlStatusBarResize($StatusBar1)
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case Else
;;;;;
EndSelect

WEnd
GUIDelete()

;================================================================
; Example 2 - External Control
;================================================================
Opt("WinTitleMatchMode", 4)
Local $h_win = WinGetHandle("classname=SciTEWindow")
Local $h_status = ControlGetHandle($h_win, "", "msctls_statusbar321")
Local $s_text = _GUICtrlStatusBarGetText($h_status)
Local $Unicode = _GUICtrlStatusBarGetUnicode($h_status)
If $Unicode Then
_GUICtrlStatusBarSetUnicode($StatusBar1, False)
If _GUICtrlStatusBarGetUnicode($h_status) Then
_GUICtrlStatusBarSetText($h_status, "Was using Unicode characters, Not Now")
Else
_GUICtrlStatusBarSetText($h_status, "Couldn't turn off Unicode")
EndIf
Else
_GUICtrlStatusBarSetUnicode($StatusBar1)
If Not _GUICtrlStatusBarGetUnicode($h_status) Then
_GUICtrlStatusBarSetText($h_status, "Was NOT using Unicode characters, Is Now")
Else
_GUICtrlStatusBarSetText($h_status, "Couldn't turn on Unicode")
EndIf
EndIf
Sleep(10000)
_GUICtrlStatusBarSetUnicode($StatusBar1, $Unicode)
_GUICtrlStatusBarSetText($h_status, $s_text)


Function _GUICtrlStatusBarShowHide

Function Reference

_GUICtrlStatusBarShowHide

Show/Hide the StatusBar control

#Include <GuiStatusBar.au3>
_GUICtrlStatusBarShowHide ( hwnd, state )

Parameters

hwnd | Handle to statusbar
state | @SW_SHOW/@SW_HIDE

Return Value

If the window was previously visible, the return value is nonzero
If the window was previously hidden, the return value is zero
If the function fails, the return value is zero

Remarks

None.

Related

_GUICtrlStatusBarCreate, _GUICtrlStatusBarDelete

Example

opt("MustDeclareVars", 1)

#include <GUIConstants.au3>
#Include <GuiStatusBar.au3>

Local $gui, $StatusBar1, $msg, $btn_ShowHide, $Hidden = 0
Local $a_PartsRightEdge[3] = [100, 350, -1]
Local $a_PartsText[3] = ["New Text", "More Text", "Even More Text"]

$gui = GUICreate("Status Bar Show/Hide", 500, -1, -1, -1, $WS_SIZEBOX)
$StatusBar1 = _GUICtrlStatusBarCreate ($gui, $a_PartsRightEdge, $a_PartsText)
$btn_ShowHide = GUICtrlCreateButton("Show/Hide StatusBar", 10, 10, 120, 25)

GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_RESIZED
_GUICtrlStatusBarResize ($StatusBar1)
Case $msg = $btn_ShowHide
If $Hidden Then
_GuiCtrlStatusBarShowHide($StatusBar1, @SW_SHOW)
Else
_GuiCtrlStatusBarShowHide($StatusBar1, @SW_HIDE)
EndIf
$Hidden = Not $Hidden
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case Else
;;;;;
EndSelect

WEnd


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: GuiTab Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_GUICtrlTabDeleteAllItems | Removes all items from a tab control.
_GUICtrlTabDeleteItem | Removes an item from a tab control.
_GUICtrlTabDeselectAll | Resets items in a tab control.
_GUICtrlTabGetCurFocus | Returns the index of the item that has the focus in a tab control.
_GUICtrlTabGetCurSel | Determines the currently selected tab in a tab control.
_GUICtrlTabGetExtendedStyle | Retrieves the extended styles that are currently in use for the tab control.
_GUICtrlTabGetItemCount | Retrieves the number of tabs in the tab control.
_GUICtrlTabGetItemRECT | Retrieves the bounding rectangle for a tab in a tab control.
_GUICtrlTabGetRowCount | Retrieves the current number of rows of tabs in a tab control.
_GUICtrlTabGetUnicodeFormat | Retrieves the Unicode character format flag for the control.
_GUICtrlTabHighlightItem | Sets the highlight state of a tab item.
_GUICtrlTabSetCurFocus | Sets the focus to a specified tab in a tab control.
_GUICtrlTabSetCurSel | Selects a tab in a tab control.
_GUICtrlTabSetMinTabWidth | Sets the minimum width of items in a tab control.
_GUICtrlTabSetUnicodeFormat | Sets the Unicode character format flag for the control.


Function _GUICtrlTabDeleteAllItems

Function Reference

_GUICtrlTabDeleteAllItems

Removes all items from a tab control.

#Include <GuiTab.au3>
_GUICtrlTabDeleteAllItems ( $h_tabcontrol )

Parameters

$h_tabcontrol control id/control hWnd

Return Value

Returns TRUE if successful, or FALSE otherwise.

Remarks

This does not delete the controls on the tabitems

Related

_GUICtrlTabDeleteItem

Example

#include <GUIConstants.au3>
#include <GuiTab.au3>

opt('MustDeclareVars', 1)

Dim $tab, $tab0, $tab0OK, $tab0input, $tab1, $tab1combo, $tab1OK, $tab2, $tab2OK, $tab3, $tab4, $button, $msg
GUICreate("Tab Delete All Items", 300, 200) ; will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab = GUICtrlCreateTab(10, 10, 200, 100, $TCS_MULTILINE)

$tab0 = GUICtrlCreateTabItem("tab0")
GUICtrlCreateLabel("label0", 30, 80, 50, 20)
$tab0OK = GUICtrlCreateButton("OK0", 20, 60, 50, 20)
$tab0input = GUICtrlCreateInput("default", 80, 60, 70, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab1 = GUICtrlCreateTabItem("tab----1")
GUICtrlCreateLabel("label1", 30, 80, 50, 20)
$tab1combo = GUICtrlCreateCombo("", 20, 60, 60, 40)
GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon
$tab1OK = GUICtrlCreateButton("OK1", 80, 60, 50, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab2 = GUICtrlCreateTabItem("tab2")
GUICtrlSetState(-1, $GUI_SHOW) ; will be display first
GUICtrlCreateLabel("label2", 30, 80, 50, 20)
$tab2OK = GUICtrlCreateButton("OK2", 140, 60, 50)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab3 = GUICtrlCreateTabItem("tab3")
GUICtrlCreateTabItem("") ; end tabitem definition

$tab4 = GUICtrlCreateTabItem("tab4")
GUICtrlCreateTabItem("") ; end tabitem definition

GUICtrlCreateLabel("label3", 20, 130, 50, 20)
$button = GUICtrlCreateButton("Delete All", 200, 130, 90, 30)

GUISetState()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
_GUICtrlTabDeleteAllItems ($tab)
EndSelect
WEnd


Function _GUICtrlTabDeleteItem

Function Reference

_GUICtrlTabDeleteItem

Removes an item from a tab control.

#Include <GuiTab.au3>
_GUICtrlTabDeleteItem ( $h_tabcontrol, $i_item )

Parameters

$h_tabcontrol | control id/control hWnd
$i_item | Index of the item to delete.

Return Value

Returns TRUE if successful, or FALSE otherwise.

Remarks

This does not delete the controls on the tabitem.

Related

_GUICtrlTabDeleteAllItems

Example

#include <GUIConstants.au3>
#include <GuiTab.au3>

opt('MustDeclareVars', 1)

Dim $tab, $tab0, $tab0OK, $tab0input, $tab1, $tab1combo, $tab1OK, $tab2, $tab2OK, $tab3, $tab4, $button, $msg

GUICreate("Tab Delete Item", 300, 200) ; will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab = GUICtrlCreateTab(10, 10, 200, 100, $TCS_MULTILINE)

$tab0 = GUICtrlCreateTabItem("tab0")
GUICtrlCreateLabel("label0", 30, 80, 50, 20)
$tab0OK = GUICtrlCreateButton("OK0", 20, 60, 50, 20)
$tab0input = GUICtrlCreateInput("default", 80, 60, 70, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab1 = GUICtrlCreateTabItem("tab----1")
GUICtrlCreateLabel("label1", 30, 80, 50, 20)
$tab1combo = GUICtrlCreateCombo("", 20, 60, 60, 40)
GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon
$tab1OK = GUICtrlCreateButton("OK1", 80, 60, 50, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab2 = GUICtrlCreateTabItem("tab2")
GUICtrlSetState(-1, $GUI_SHOW) ; will be display first
GUICtrlCreateLabel("label2", 30, 80, 50, 20)
$tab2OK = GUICtrlCreateButton("OK2", 140, 60, 50)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab3 = GUICtrlCreateTabItem("tab3")
GUICtrlCreateTabItem("") ; end tabitem definition

$tab4 = GUICtrlCreateTabItem("tab4")
GUICtrlCreateTabItem("") ; end tabitem definition

GUICtrlCreateLabel("label3", 20, 130, 50, 20)
$button = GUICtrlCreateButton("Delete", 200, 130, 90, 30)

GUISetState()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
_GUICtrlTabDeleteItem ($tab, 2)
EndSelect
WEnd


Function _GUICtrlTabDeselectAll

Function Reference

_GUICtrlTabDeselectAll

Resets items in a tab control.

#Include <GuiTab.au3>
_GUICtrlTabDeselectAll ( $h_tabcontrol, $i_bool )

Parameters

$h_tabcontrol | control id/control hWnd
$i_bool | Flag that specifies the scope of the item deselection. If this parameter is set to FALSE, all tab items will be reset. If it is set to TRUE, then all tab items except for the one currently selected will be reset.

Return Value

None.

Remarks

This only works if $TCS_BUTTONS style flag has been set.

Related

_GUICtrlTabGetCurSel, _GUICtrlTabSetCurSel

Example

#include <GUIConstants.au3>
#include <GuiTab.au3>

opt('MustDeclareVars', 1)

Dim $tab, $tab0, $tab0OK, $tab0input, $tab1, $tab1combo, $tab1OK, $tab2, $tab2OK, $tab3, $tab4, $button, $msg

GUICreate("Tab Deselect All", 300, 200) ; will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab = GUICtrlCreateTab(10, 10, 200, 100, BitOR($TCS_BUTTONS, $TCS_MULTILINE))

$tab0 = GUICtrlCreateTabItem("tab0")
GUICtrlCreateLabel("label0", 30, 80, 50, 20)
$tab0OK = GUICtrlCreateButton("OK0", 20, 60, 50, 20)
$tab0input = GUICtrlCreateInput("default", 80, 60, 70, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab1 = GUICtrlCreateTabItem("tab----1")
GUICtrlCreateLabel("label1", 30, 80, 50, 20)
$tab1combo = GUICtrlCreateCombo("", 20, 60, 60, 40)
GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon
$tab1OK = GUICtrlCreateButton("OK1", 80, 60, 50, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab2 = GUICtrlCreateTabItem("tab2")
GUICtrlSetState(-1, $GUI_SHOW) ; will be display first
GUICtrlCreateLabel("label2", 30, 80, 50, 20)
$tab2OK = GUICtrlCreateButton("OK2", 140, 60, 50)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab3 = GUICtrlCreateTabItem("tab3")
GUICtrlCreateTabItem("") ; end tabitem definition

$tab4 = GUICtrlCreateTabItem("tab4")
GUICtrlCreateTabItem("") ; end tabitem definition

GUICtrlCreateLabel("label3", 20, 130, 50, 20)
$button = GUICtrlCreateButton("Deselect All", 200, 130, 90, 30)

GUISetState()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
_GUICtrlTabDeselectAll ($tab, 0)
EndSelect
WEnd


Function _GUICtrlTabGetCurFocus

Function Reference

_GUICtrlTabGetCurFocus

Returns the index of the item that has the focus in a tab control.

#Include <GuiTab.au3>
_GUICtrlTabGetCurFocus ( $h_tabcontrol )

Parameters

$h_tabcontrol control id/control hWnd

Return Value

Returns the index of the tab item that has the focus.

Remarks

The item that has the focus may be different than the selected item.

Related

_GUICtrlTabSetCurFocus

Example

#include <GUIConstants.au3>
#include <GuiTab.au3>

opt('MustDeclareVars', 1)

Dim $tab, $tab0, $tab0OK, $tab0input, $tab1, $tab1combo, $tab1OK, $tab2, $tab2OK, $tab3, $tab4
Dim $msg, $Status, $current

GUICreate("Tab Get Current Focus", 300, 200) ; will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab = GUICtrlCreateTab(10, 10, 200, 100, BitOR($TCS_FLATBUTTONS, $TCS_MULTILINE), $TCS_EX_FLATSEPARATORS)

$tab0 = GUICtrlCreateTabItem("tab0")
GUICtrlCreateLabel("label0", 30, 80, 50, 20)
$tab0OK = GUICtrlCreateButton("OK0", 20, 60, 50, 20)
$tab0input = GUICtrlCreateInput("default", 80, 60, 70, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab1 = GUICtrlCreateTabItem("tab----1")
GUICtrlCreateLabel("label1", 30, 80, 50, 20)
$tab1combo = GUICtrlCreateCombo("", 20, 60, 60, 40)
GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon
$tab1OK = GUICtrlCreateButton("OK1", 80, 60, 50, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab2 = GUICtrlCreateTabItem("tab2")
GUICtrlSetState(-1, $GUI_SHOW) ; will be display first
GUICtrlCreateLabel("label2", 30, 80, 50, 20)
$tab2OK = GUICtrlCreateButton("OK2", 140, 60, 50)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab3 = GUICtrlCreateTabItem("tab3")
GUICtrlCreateTabItem("") ; end tabitem definition

$tab4 = GUICtrlCreateTabItem("tab4")
GUICtrlCreateTabItem("") ; end tabitem definition

GUICtrlCreateLabel("label3", 20, 130, 50, 20)
$Status = GUICtrlCreateLabel("", 0, 180, 300, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()

$current = _GUICtrlTabGetCurFocus ($tab)
GUICtrlSetData($Status, "Items Current Focus: " & $current)

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
If ($current <> _GUICtrlTabGetCurFocus ($tab)) Then
$current = _GUICtrlTabGetCurFocus ($tab)
GUICtrlSetData($Status, "Items Current Focus: " & $current)
EndIf
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd


Function _GUICtrlTabGetCurSel

Function Reference

_GUICtrlTabGetCurSel

Determines the currently selected tab in a tab control.

#Include <GuiTab.au3>
_GUICtrlTabGetCurSel ( $h_tabcontrol )

Parameters

$h_tabcontrol control id/control hWnd

Return Value

Returns the index of the selected tab if successful, or $TC_ERR if no tab is selected.

Remarks

None.

Related

_GUICtrlTabSetCurSel

Example

#include <GUIConstants.au3>
#include <GuiTab.au3>

opt('MustDeclareVars', 1)

Dim $tab, $tab0, $tab0OK, $tab0input, $tab1, $tab1combo, $tab1OK, $tab2, $tab2OK, $tab3, $tab4
Dim $msg, $Status, $current, $button

GUICreate("Tab Get Current Selection", 300, 200) ; will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab = GUICtrlCreateTab(10, 10, 200, 100, $TCS_MULTILINE)

$tab0 = GUICtrlCreateTabItem("tab0")
GUICtrlCreateLabel("label0", 30, 80, 50, 20)
$tab0OK = GUICtrlCreateButton("OK0", 20, 60, 50, 20)
$tab0input = GUICtrlCreateInput("default", 80, 60, 70, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab1 = GUICtrlCreateTabItem("tab----1")
GUICtrlCreateLabel("label1", 30, 80, 50, 20)
$tab1combo = GUICtrlCreateCombo("", 20, 60, 60, 40)
GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon
$tab1OK = GUICtrlCreateButton("OK1", 80, 60, 50, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab2 = GUICtrlCreateTabItem("tab2")
GUICtrlSetState(-1, $GUI_SHOW) ; will be display first
GUICtrlCreateLabel("label2", 30, 80, 50, 20)
$tab2OK = GUICtrlCreateButton("OK2", 140, 60, 50)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab3 = GUICtrlCreateTabItem("tab3")
GUICtrlCreateTabItem("") ; end tabitem definition

$tab4 = GUICtrlCreateTabItem("tab4")
GUICtrlCreateTabItem("") ; end tabitem definition

GUICtrlCreateLabel("label3", 20, 130, 50, 20)

$Status = GUICtrlCreateLabel("", 0, 180, 300, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
GUICtrlSetData($Status, "Current Selection: " & _GUICtrlTabGetCurSel ($tab))

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $tab
GUICtrlSetData($Status, "Current Selection: " & _GUICtrlTabGetCurSel ($tab))
EndSelect
WEnd


Function _GUICtrlTabGetExtendedStyle

Function Reference

_GUICtrlTabGetExtendedStyle

Retrieves the extended styles that are currently in use for the tab control.

#Include <GuiTab.au3>
_GUICtrlTabGetExtendedStyle ( $h_tabcontrol )

Parameters

$h_tabcontrol control id/control hWnd

Return Value

Returns a DWORD value that represents the extended styles currently
in use for the tab control.
This value is a combination of tab control extended styles.

Remarks

None.

Related

None.

Example

#include <GUIConstants.au3>
#include <GuiTab.au3>

opt('MustDeclareVars', 1)

Dim $tab, $tab0, $tab0OK, $tab0input, $tab1, $tab1combo, $tab1OK, $tab2, $tab2OK, $tab3, $tab4
Dim $msg, $Styles, $i

GUICreate("Tab Get Extended Style", 300, 200) ; will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab = GUICtrlCreateTab(10, 10, 200, 100, BitOR($TCS_FLATBUTTONS, $TCS_MULTILINE), $TCS_EX_FLATSEPARATORS)

$tab0 = GUICtrlCreateTabItem("tab0")
GUICtrlCreateLabel("label0", 30, 80, 50, 20)
$tab0OK = GUICtrlCreateButton("OK0", 20, 60, 50, 20)
$tab0input = GUICtrlCreateInput("default", 80, 60, 70, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab1 = GUICtrlCreateTabItem("tab----1")
GUICtrlCreateLabel("label1", 30, 80, 50, 20)
$tab1combo = GUICtrlCreateCombo("", 20, 60, 60, 40)
GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon
$tab1OK = GUICtrlCreateButton("OK1", 80, 60, 50, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab2 = GUICtrlCreateTabItem("tab2")
GUICtrlSetState(-1, $GUI_SHOW) ; will be display first
GUICtrlCreateLabel("label2", 30, 80, 50, 20)
$tab2OK = GUICtrlCreateButton("OK2", 140, 60, 50)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab3 = GUICtrlCreateTabItem("tab3")
GUICtrlCreateTabItem("") ; end tabitem definition

$tab4 = GUICtrlCreateTabItem("tab4")
GUICtrlCreateTabItem("") ; end tabitem definition

GUICtrlCreateLabel("label3", 20, 130, 50, 20)

GUISetState()
$Styles = ""
For $i = 1 To 2
Select
Case $i = 1
If (BitAND(_GUICtrlTabGetExtendedStyle ($tab), $TCS_EX_FLATSEPARATORS) = $TCS_EX_FLATSEPARATORS) Then
$Styles &= "$TCS_EX_FLATSEPARATORS" & @LF
EndIf
Case $i = 2
If (BitAND(_GUICtrlTabGetExtendedStyle ($tab), $TCS_EX_REGISTERDROP) = $TCS_EX_REGISTERDROP) Then
$Styles &= "$TCS_EX_REGISTERDROP" & @LF
EndIf
EndSelect
Next
If ($Styles) Then
MsgBox(0, "Extend Styles found", $Styles)
EndIf

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd


Function _GUICtrlTabGetItemCount

Function Reference

_GUICtrlTabGetItemCount

Retrieves the number of tabs in the tab control.

#Include <GuiTab.au3>
_GUICtrlTabGetItemCount ( $h_tabcontrol )

Parameters

$h_tabcontrol control id/control hWnd

Return Value

Returns the number of items if successful, or zero otherwise.

Remarks

None.

Related

_GUICtrlTabGetRowCount

Example

#include <GUIConstants.au3>
#include <GuiTab.au3>

opt('MustDeclareVars', 1)

Dim $tab, $tab0, $tab0OK, $tab0input, $tab1, $tab1combo, $tab1OK, $tab2, $tab2OK, $tab3, $tab4
Dim $msg, $Status

GUICreate("Tab Get Item Count", 300, 200) ; will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab = GUICtrlCreateTab(10, 10, 200, 100, BitOR($TCS_FLATBUTTONS, $TCS_MULTILINE), $TCS_EX_FLATSEPARATORS)

$tab0 = GUICtrlCreateTabItem("tab0")
GUICtrlCreateLabel("label0", 30, 80, 50, 20)
$tab0OK = GUICtrlCreateButton("OK0", 20, 60, 50, 20)
$tab0input = GUICtrlCreateInput("default", 80, 60, 70, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab1 = GUICtrlCreateTabItem("tab----1")
GUICtrlCreateLabel("label1", 30, 80, 50, 20)
$tab1combo = GUICtrlCreateCombo("", 20, 60, 60, 40)
GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon
$tab1OK = GUICtrlCreateButton("OK1", 80, 60, 50, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab2 = GUICtrlCreateTabItem("tab2")
GUICtrlSetState(-1, $GUI_SHOW) ; will be display first
GUICtrlCreateLabel("label2", 30, 80, 50, 20)
$tab2OK = GUICtrlCreateButton("OK2", 140, 60, 50)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab3 = GUICtrlCreateTabItem("tab3")
GUICtrlCreateTabItem("") ; end tabitem definition

$tab4 = GUICtrlCreateTabItem("tab4")
GUICtrlCreateTabItem("") ; end tabitem definition

GUICtrlCreateLabel("label3", 20, 130, 50, 20)

$Status = GUICtrlCreateLabel("", 0, 180, 300, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
GUICtrlSetData($Status, "Items: " & _GUICtrlTabGetItemCount ($tab))

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd


Function _GUICtrlTabGetItemRECT

Function Reference

_GUICtrlTabGetItemRECT

Retrieves the bounding rectangle for a tab in a tab control.

#Include <GuiTab.au3>
_GUICtrlTabGetItemRECT ( $h_tabcontrol, $i_item )

Parameters

$h_tabcontrol | control id/control hWnd
$i_item | Zero-based index of a tab control item.

Return Value

Array containing the RECT, first element ($array[0]) contains the number of elements
If an error occurs, the return value is $TC_ERR.

Remarks

None.

Related

None.

Example

#include <GUIConstants.au3>
#include <GuiTab.au3>

opt('MustDeclareVars', 1)

Dim $tab, $tab0, $tab0OK, $tab0input, $tab1, $tab1combo, $tab1OK, $tab2, $tab2OK, $tab3, $tab4
Dim $msg, $button, $label_rect, $s_rect

GUICreate("Tab Get Item RECT", 400, 200) ; will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab = GUICtrlCreateTab(10, 10, 200, 100, BitOR($TCS_FLATBUTTONS, $TCS_MULTILINE), $TCS_EX_FLATSEPARATORS)

$tab0 = GUICtrlCreateTabItem("tab0")
GUICtrlCreateLabel("label0", 30, 80, 50, 20)
$tab0OK = GUICtrlCreateButton("OK0", 20, 60, 50, 20)
$tab0input = GUICtrlCreateInput("default", 80, 60, 70, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab1 = GUICtrlCreateTabItem("tab----1")
GUICtrlCreateLabel("label1", 30, 80, 50, 20)
$tab1combo = GUICtrlCreateCombo("", 20, 60, 60, 40)
GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon
$tab1OK = GUICtrlCreateButton("OK1", 80, 60, 50, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab2 = GUICtrlCreateTabItem("tab2")
GUICtrlSetState(-1, $GUI_SHOW) ; will be display first
GUICtrlCreateLabel("label2", 30, 80, 50, 20)
$tab2OK = GUICtrlCreateButton("OK2", 140, 60, 50)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab3 = GUICtrlCreateTabItem("tab3")
GUICtrlCreateTabItem("") ; end tabitem definition

$tab4 = GUICtrlCreateTabItem("tab4")
GUICtrlCreateTabItem("") ; end tabitem definition

GUICtrlCreateLabel("label3", 20, 130, 50, 20)
$button = GUICtrlCreateButton("Get RECT", 200, 130, 90, 30)

$s_rect = "Left:" & @LF & "Top:" & @LF & "Right:" & @LF & "Bottom:"
$label_rect = GUICtrlCreateLabel($s_rect, 250, 20, 100, 65, $SS_SUNKEN)

GUISetState()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
Local $rect_array = _GUICtrlTabGetItemRECT ($tab, 0)
If (IsArray($rect_array)) Then
$s_rect = "Left:" & $rect_array[1] & @LF & "Top:" & $rect_array[2] & @LF & "Right:" & $rect_array[3] & @LF & "Bottom:" & $rect_array[4]
GUICtrlSetData($label_rect, $s_rect)
EndIf
EndSelect
WEnd


Function _GUICtrlTabGetRowCount

Function Reference

_GUICtrlTabGetRowCount

Retrieves the current number of rows of tabs in a tab control.

#Include <GuiTab.au3>
_GUICtrlTabGetRowCount ( $h_tabcontrol )

Parameters

$h_tabcontrol control id/control hWnd

Return Value

Returns the number of rows of tabs.

Remarks

Only tab controls that have the $TCS_MULTILINE style can have multiple rows of tabs.

Related

_GUICtrlTabGetItemCount

Example

#include <GUIConstants.au3>
#include <GuiTab.au3>

opt('MustDeclareVars', 1)

Dim $tab, $tab0, $tab0OK, $tab0input, $tab1, $tab1combo, $tab1OK, $tab2, $tab2OK, $tab3, $tab4
Dim $msg, $Status

GUICreate("Tab Get Row Count", 300, 200) ; will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab = GUICtrlCreateTab(10, 10, 200, 100, $TCS_MULTILINE)

$tab0 = GUICtrlCreateTabItem("tab0")
GUICtrlCreateLabel("label0", 30, 80, 50, 20)
$tab0OK = GUICtrlCreateButton("OK0", 20, 60, 50, 20)
$tab0input = GUICtrlCreateInput("default", 80, 60, 70, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab1 = GUICtrlCreateTabItem("tab----1")
GUICtrlCreateLabel("label1", 30, 80, 50, 20)
$tab1combo = GUICtrlCreateCombo("", 20, 60, 60, 40)
GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon
$tab1OK = GUICtrlCreateButton("OK1", 80, 60, 50, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab2 = GUICtrlCreateTabItem("tab2")
GUICtrlSetState(-1, $GUI_SHOW) ; will be display first
GUICtrlCreateLabel("label2", 30, 80, 50, 20)
$tab2OK = GUICtrlCreateButton("OK2", 140, 60, 50)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab3 = GUICtrlCreateTabItem("tab3")
GUICtrlCreateTabItem("") ; end tabitem definition

$tab4 = GUICtrlCreateTabItem("tab4")
GUICtrlCreateTabItem("") ; end tabitem definition

GUICtrlCreateLabel("label3", 20, 130, 50, 20)

$Status = GUICtrlCreateLabel("", 0, 180, 300, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
GUICtrlSetData($Status, "Row Count: " & _GUICtrlTabGetRowCount ($tab))

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd


Function _GUICtrlTabGetUnicodeFormat

Function Reference

_GUICtrlTabGetUnicodeFormat

Retrieves the Unicode character format flag for the control.

#Include <GuiTab.au3>
_GUICtrlTabGetUnicodeFormat ( $h_tabcontrol )

Parameters

$h_tabcontrol control id/control hWnd

Return Value

Returns the Unicode format flag for the control.
If this value is nonzero, the control is using Unicode characters.
If this value is zero, the control is using ANSI characters.

Remarks

None.

Related

_GUICtrlTabSetUnicodeFormat

Example

#include <GUIConstants.au3>
#include <GuiTab.au3>

opt('MustDeclareVars', 1)

Dim $tab, $tab0, $tab0OK, $tab0input, $tab1, $tab1combo, $tab1OK, $tab2, $tab2OK, $tab3, $tab4
Dim $msg, $Status

GUICreate("Tab Get Unicode Format", 300, 200) ; will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab = GUICtrlCreateTab(10, 10, 200, 100, $TCS_MULTILINE)

$tab0 = GUICtrlCreateTabItem("tab0")
GUICtrlCreateLabel("label0", 30, 80, 50, 20)
$tab0OK = GUICtrlCreateButton("OK0", 20, 60, 50, 20)
$tab0input = GUICtrlCreateInput("default", 80, 60, 70, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab1 = GUICtrlCreateTabItem("tab----1")
GUICtrlCreateLabel("label1", 30, 80, 50, 20)
$tab1combo = GUICtrlCreateCombo("", 20, 60, 60, 40)
GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon
$tab1OK = GUICtrlCreateButton("OK1", 80, 60, 50, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab2 = GUICtrlCreateTabItem("tab2")
GUICtrlSetState(-1, $GUI_SHOW) ; will be display first
GUICtrlCreateLabel("label2", 30, 80, 50, 20)
$tab2OK = GUICtrlCreateButton("OK2", 140, 60, 50)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab3 = GUICtrlCreateTabItem("tab3")
GUICtrlCreateTabItem("") ; end tabitem definition

$tab4 = GUICtrlCreateTabItem("tab4")
GUICtrlCreateTabItem("") ; end tabitem definition

GUICtrlCreateLabel("label3", 20, 130, 50, 20)

$Status = GUICtrlCreateLabel("", 0, 180, 300, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()
If (_GUICtrlTabGetUnicodeFormat ($tab)) Then
GUICtrlSetData($Status, "Unicode Format")
Else
GUICtrlSetData($Status, "ANSI Characters")
EndIf

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd


Function _GUICtrlTabHighlightItem

Function Reference

_GUICtrlTabHighlightItem

Sets the highlight state of a tab item.

#Include <GuiTab.au3>
_GUICtrlTabHighlightItem ( $h_tabcontrol, $i_item, $i_bool )

Parameters

$h_tabcontrol | control id/control hWnd
$i_item | Zero-based index of a tab control item.
$i_bool | Value specifying the highlight state to be set. If this value is TRUE, the tab is highlighted If FALSE, the tab is set to its default state.

Return Value

Returns nonzero if successful, or zero otherwise.

Remarks

None.

Related

_GUICtrlTabSetCurSel

Example

#include <GUIConstants.au3>
#include <GuiTab.au3>

opt('MustDeclareVars', 1)

Dim $tab, $tab0, $tab0OK, $tab0input, $tab1, $tab1combo, $tab1OK, $tab2, $tab2OK, $tab3, $tab4
Dim $msg, $button, $bool

GUICreate("Tab Highlight Item", 300, 200) ; will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab = GUICtrlCreateTab(10, 10, 200, 100, $TCS_MULTILINE)

$tab0 = GUICtrlCreateTabItem("tab0")
GUICtrlCreateLabel("label0", 30, 80, 50, 20)
$tab0OK = GUICtrlCreateButton("OK0", 20, 60, 50, 20)
$tab0input = GUICtrlCreateInput("default", 80, 60, 70, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab1 = GUICtrlCreateTabItem("tab----1")
GUICtrlCreateLabel("label1", 30, 80, 50, 20)
$tab1combo = GUICtrlCreateCombo("", 20, 60, 60, 40)
GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon
$tab1OK = GUICtrlCreateButton("OK1", 80, 60, 50, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab2 = GUICtrlCreateTabItem("tab2")
GUICtrlSetState(-1, $GUI_SHOW) ; will be display first
GUICtrlCreateLabel("label2", 30, 80, 50, 20)
$tab2OK = GUICtrlCreateButton("OK2", 140, 60, 50)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab3 = GUICtrlCreateTabItem("tab3")
GUICtrlCreateTabItem("") ; end tabitem definition

$tab4 = GUICtrlCreateTabItem("tab4")
GUICtrlCreateTabItem("") ; end tabitem definition

GUICtrlCreateLabel("label3", 20, 130, 50, 20)
$button = GUICtrlCreateButton("Highlight", 200, 130, 90, 30)

GUISetState()

$bool = 0
; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$bool = Not $bool
_GUICtrlTabHighlightItem ($tab, 2, $bool)
EndSelect
WEnd


Function _GUICtrlTabSetCurFocus

Function Reference

_GUICtrlTabSetCurFocus

Sets the focus to a specified tab in a tab control.

#Include <GuiTab.au3>
_GUICtrlTabSetCurFocus ( $h_tabcontrol, $i_item )

Parameters

$h_tabcontrol | control id/control hWnd
$i_item | Zero-based index of a tab control item.

Return Value

None.

Remarks

If the tab control has the $TCS_BUTTONS style (button mode),
the tab with the focus may be different from the selected tab.

For example, when a tab is selected, the user can press the arrow
keys to set the focus to a different tab without changing the selected tab.

In button mode, $TCM_SETCURFOCUS sets the input focus to the button associated
with the specified tab, but it does not change the selected tab.

If the tab control does not have the $TCS_BUTTONS style, changing the focus
also changes the selected tab.

Related

_GUICtrlTabGetCurFocus

Example

#include <GUIConstants.au3>
#include <GuiTab.au3>

opt('MustDeclareVars', 1)

Dim $tab, $tab0, $tab0OK, $tab0input, $tab1, $tab1combo, $tab1OK, $tab2, $tab2OK, $tab3, $tab4
Dim $msg, $button, $item = 0

GUICreate("Tab Set Current Focus", 300, 200) ; will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab = GUICtrlCreateTab(10, 10, 200, 100, $TCS_MULTILINE)

$tab0 = GUICtrlCreateTabItem("tab0")
GUICtrlCreateLabel("label0", 30, 80, 50, 20)
$tab0OK = GUICtrlCreateButton("OK0", 20, 60, 50, 20)
$tab0input = GUICtrlCreateInput("default", 80, 60, 70, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab1 = GUICtrlCreateTabItem("tab----1")
GUICtrlCreateLabel("label1", 30, 80, 50, 20)
$tab1combo = GUICtrlCreateCombo("", 20, 60, 60, 40)
GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon
$tab1OK = GUICtrlCreateButton("OK1", 80, 60, 50, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab2 = GUICtrlCreateTabItem("tab2")
GUICtrlSetState(-1, $GUI_SHOW) ; will be display first
GUICtrlCreateLabel("label2", 30, 80, 50, 20)
$tab2OK = GUICtrlCreateButton("OK2", 140, 60, 50)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab3 = GUICtrlCreateTabItem("tab3")
GUICtrlCreateTabItem("") ; end tabitem definition

$tab4 = GUICtrlCreateTabItem("tab4")
GUICtrlCreateTabItem("") ; end tabitem definition

GUICtrlCreateLabel("label3", 20, 130, 50, 20)
$button = GUICtrlCreateButton("Set", 200, 130, 90, 30)

GUISetState()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
_GUICtrlTabSetCurFocus ($tab, $item)
$item = Not $item
EndSelect
WEnd


Function _GUICtrlTabSetCurSel

Function Reference

_GUICtrlTabSetCurSel

Selects a tab in a tab control.

#Include <GuiTab.au3>
_GUICtrlTabSetCurSel ( $h_tabcontrol, $i_item )

Parameters

$h_tabcontrol | control id/control hWnd
$i_item | Zero-based index of a tab control item.

Return Value

Returns the index of the previously selected tab if successful, or $TC_ERR otherwise.

Remarks

A tab control does not send a $TCN_SELCHANGING or $TCN_SELCHANGE
notification message when a tab is selected using this message.

Related

_GUICtrlTabSetCurFocus, _GUICtrlTabGetCurSel

Example

#include <GUIConstants.au3>
#include <GuiTab.au3>

opt('MustDeclareVars', 1)

Dim $tab, $tab0, $tab0OK, $tab0input, $tab1, $tab1combo, $tab1OK, $tab2, $tab2OK, $tab3, $tab4
Dim $msg, $Status, $current, $button, $item = 0

GUICreate("Tab Set Current Selection", 300, 200) ; will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab = GUICtrlCreateTab(10, 10, 200, 100, $TCS_MULTILINE)

$tab0 = GUICtrlCreateTabItem("tab0")
GUICtrlCreateLabel("label0", 30, 80, 50, 20)
$tab0OK = GUICtrlCreateButton("OK0", 20, 60, 50, 20)
$tab0input = GUICtrlCreateInput("default", 80, 60, 70, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab1 = GUICtrlCreateTabItem("tab----1")
GUICtrlCreateLabel("label1", 30, 80, 50, 20)
$tab1combo = GUICtrlCreateCombo("", 20, 60, 60, 40)
GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon
$tab1OK = GUICtrlCreateButton("OK1", 80, 60, 50, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab2 = GUICtrlCreateTabItem("tab2")
GUICtrlSetState(-1, $GUI_SHOW) ; will be display first
GUICtrlCreateLabel("label2", 30, 80, 50, 20)
$tab2OK = GUICtrlCreateButton("OK2", 140, 60, 50)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab3 = GUICtrlCreateTabItem("tab3")
GUICtrlCreateTabItem("") ; end tabitem definition

$tab4 = GUICtrlCreateTabItem("tab4")
GUICtrlCreateTabItem("") ; end tabitem definition

GUICtrlCreateLabel("label3", 20, 130, 50, 20)
$button = GUICtrlCreateButton("Set", 200, 130, 90, 30)

$Status = GUICtrlCreateLabel("", 0, 180, 300, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
_GUICtrlTabSetCurSel ($tab, $item)
$item = Not $item
EndSelect
WEnd


Function _GUICtrlTabSetMinTabWidth

Function Reference

_GUICtrlTabSetMinTabWidth

Sets the minimum width of items in a tab control.

#Include <GuiTab.au3>
_GUICtrlTabSetMinTabWidth ( $h_tabcontrol, $i_width )

Parameters

$h_tabcontrol | control id/control hWnd
i_width | Minimum width to be set for a tab control item. If this parameter is set to -1, the control will use the default tab width

Return Value

Returns an INT value that represents the previous minimum tab width.

Remarks

None.

Related

None.

Example

#include <GUIConstants.au3>
#include <GuiTab.au3>

opt('MustDeclareVars', 1)

Dim $tab, $tab0, $tab0OK, $tab0input, $tab1, $tab1combo, $tab1OK, $tab2, $tab2OK
Dim $msg, $button

GUICreate("Tab Set Min Tab Width", 300, 200) ; will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab = GUICtrlCreateTab(10, 10, 200, 100)

$tab0 = GUICtrlCreateTabItem("tab0")
GUICtrlCreateLabel("label0", 30, 80, 50, 20)
$tab0OK = GUICtrlCreateButton("OK0", 20, 60, 50, 20)
$tab0input = GUICtrlCreateInput("default", 80, 60, 70, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab1 = GUICtrlCreateTabItem("tab----1")
GUICtrlCreateLabel("label1", 30, 80, 50, 20)
$tab1combo = GUICtrlCreateCombo("", 20, 60, 60, 40)
GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon
$tab1OK = GUICtrlCreateButton("OK1", 80, 60, 50, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab2 = GUICtrlCreateTabItem("tab2")
GUICtrlSetState(-1, $GUI_SHOW) ; will be display first
GUICtrlCreateLabel("label2", 30, 80, 50, 20)
$tab2OK = GUICtrlCreateButton("OK2", 140, 60, 50)
GUICtrlCreateTabItem("") ; end tabitem definition

GUICtrlCreateLabel("label3", 20, 130, 50, 20)
$button = GUICtrlCreateButton("Set", 200, 130, 90, 30)

GUISetState()
_GUICtrlTabSetMinTabWidth ($tab, 15)

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
_GUICtrlTabSetMinTabWidth ($tab, 65)
EndSelect
WEnd


Function _GUICtrlTabSetUnicodeFormat

Function Reference

_GUICtrlTabSetUnicodeFormat

Sets the Unicode character format flag for the control.

#Include <GuiTab.au3>
_GUICtrlTabSetUnicodeFormat ( $h_tabcontrol, $i_bool )

Parameters

$h_tabcontrol | control id/control hWnd
$i_bool | Determines the character set that is used by the control. If this value is nonzero, the control will use Unicode characters. If this value is zero, the control will use ANSI characters.

Return Value

Returns the previous Unicode format flag for the control.

Remarks

None.

Related

_GUICtrlTabGetUnicodeFormat

Example

#include <GUIConstants.au3>
#include <GuiTab.au3>

opt('MustDeclareVars', 1)

Dim $tab, $tab0, $tab0OK, $tab0input, $tab1, $tab1combo, $tab1OK, $tab2, $tab2OK
Dim $msg, $Status, $format = 0, $button, $ret

GUICreate("Tab Set Unicode Format", 300, 200) ; will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab = GUICtrlCreateTab(10, 10, 200, 100)

$tab0 = GUICtrlCreateTabItem("tab0")
GUICtrlCreateLabel("label0", 30, 80, 50, 20)
$tab0OK = GUICtrlCreateButton("OK0", 20, 60, 50, 20)
$tab0input = GUICtrlCreateInput("default", 80, 60, 70, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab1 = GUICtrlCreateTabItem("tab----1")
GUICtrlCreateLabel("label1", 30, 80, 50, 20)
$tab1combo = GUICtrlCreateCombo("", 20, 60, 60, 40)
GUICtrlSetData(-1, "Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon
$tab1OK = GUICtrlCreateButton("OK1", 80, 60, 50, 20)
GUICtrlCreateTabItem("") ; end tabitem definition

$tab2 = GUICtrlCreateTabItem("tab2")
GUICtrlSetState(-1, $GUI_SHOW) ; will be display first
GUICtrlCreateLabel("label2", 30, 80, 50, 20)
$tab2OK = GUICtrlCreateButton("OK2", 140, 60, 50)
GUICtrlCreateTabItem("") ; end tabitem definition

GUICtrlCreateLabel("label3", 20, 130, 50, 20)
$button = GUICtrlCreateButton("Set", 200, 130, 90, 30)

$Status = GUICtrlCreateLabel("", 0, 180, 300, 20, BitOR($SS_SUNKEN, $SS_CENTER))

GUISetState()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
$ret = _GUICtrlTabSetUnicodeFormat ($tab, $format)
If ($ret) Then
GUICtrlSetData($Status, "Now ANSI Characters, was Unicode Format")
Else
GUICtrlSetData($Status, "Now Unicode Format, was ANSI Characters")
EndIf
$format = Not $format
EndSelect
WEnd


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: GuiTreeView Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_GUICtrlTreeViewDeleteAllItems | Removes all items from a treeview control.
_GUICtrlTreeViewDeleteItem | Removes an item and all its children from a treeview control.
_GUICtrlTreeViewExpand | Expands or collapses the list of child items associated with the specified parent item, if any.
_GUICtrlTreeViewGetBkColor | Gets the text back color of a treeview control.
_GUICtrlTreeViewGetCount | Retrieves a count of the items in a treeview control.
_GUICtrlTreeViewGetIndent | Retrieves the amount in pixels, that child items are indented relative to their parent items.
_GUICtrlTreeViewGetLineColor | Gets the line color of a treeview control.
_GUICtrlTreeViewGetParentHandle | Gets the parent handle of item selected (default) or any specified item in treeview control.
_GUICtrlTreeViewGetParentID | Gets the parent control ID of item selected (default) or any specified item in treeview control.
_GUICtrlTreeViewGetState | Returns the state of the specified treeview item.
_GUICtrlTreeViewGetText | Returns the text of the specified treeview item.
_GUICtrlTreeViewGetTextColor | Gets the text color of a treeview control.
_GUICtrlTreeViewGetTree | Get all items text beginning by the current selected item from the treeview control.
_GUICtrlTreeViewInsertItem | Insert a new item into a treeview control.
_GUICtrlTreeViewSetBkColor | Sets the back color of a treeview control.
_GUICtrlTreeViewSetIcon | Set an icon of the specified treeview item.
_GUICtrlTreeViewSetIndent | Sets the width of indentation for a treeview control and redraws the control to reflect the new width.
_GUICtrlTreeViewSetLineColor | Sets the line color of a treeview control
_GUICtrlTreeViewSetState | Set the state of the specified treeview item.
_GUICtrlTreeViewSetText | Set a new text to the specified treeview item.
_GUICtrlTreeViewSetTextColor | Sets the text color of a treeview control.
_GUICtrlTreeViewSort | Sorts the items of a treeview control.


Function _GUICtrlTreeViewDeleteAllItems

Function Reference

_GUICtrlTreeViewDeleteAllItems

Removes all items from a treeview control.

#Include <GuiTreeView.au3>
_GUICtrlTreeViewDeleteAllItems ( $i_treeview )

Parameters

$i_treeview controlID

Return Value

Returns TRUE if successful, or FALSE otherwise.

Remarks

None.

Related

_GUICtrlTreeViewDeleteItem

Example

#include <GuiTreeView.au3>

opt("MustDeclareVars", 1)
opt("GUIDataSeparatorChar", "\")
Dim $h_GUI, $treeview, $nItem1, $nItem2, $nSubItem1, $nSubItem2, $nSubItem3, $nSubItem4, $Btn_DeleteAll, $Msg

$h_GUI = GUICreate("TreeView Delete All Items", 392, 254)

$treeview = GUICtrlCreateTreeView(10, 10, 150, 150)
$nItem2 = GUICtrlCreateTreeViewItem("Item2", $treeview)
$nItem1 = GUICtrlCreateTreeViewItem("Item1", $treeview)
$nSubItem2 = GUICtrlCreateTreeViewItem("SubItem2", $nItem1)
$nSubItem1 = GUICtrlCreateTreeViewItem("SubItem1", $nItem1)
$nSubItem4 = GUICtrlCreateTreeViewItem("SubItem4", $nSubItem1)
$nSubItem3 = GUICtrlCreateTreeViewItem("SubItem3", $nSubItem1)

$Btn_DeleteAll = GUICtrlCreateButton("Delete All", 70, 170, 70, 20)

GUISetState()

While 1
$Msg = GUIGetMsg()
Select
Case $Msg = $GUI_EVENT_CLOSE
ExitLoop
Case $Msg = $Btn_DeleteAll
_GUICtrlTreeViewDeleteAllItems ($treeview)
EndSelect
WEnd

Exit


Function _GUICtrlTreeViewDeleteItem

Function Reference

_GUICtrlTreeViewDeleteItem

Removes an item and all its children from a treeview control.

#Include <GuiTreeView.au3>
_GUICtrlTreeViewDeleteItem ( $h_wnd, $i_treeview [, $h_itemID = 0 ] )

Parameters

$h_wnd | GUI handle as returned by GUICreate....
$i_treeview | controlID
$h_itemID | Optional: item ID/handle

Return Value

Returns TRUE if successful, or FALSE otherwise.

Remarks

None.

Related

_GUICtrlTreeViewDeleteAllItems

Example

#include <GuiTreeView.au3>

opt("MustDeclareVars", 1)
opt("GUIDataSeparatorChar", "\")
Dim $h_GUI, $treeview, $nItem1, $nItem2, $nSubItem1, $nSubItem2, $nSubItem3, $nSubItem4
Dim $Btn_Delete, $Btn_DeleteItem, $Msg

$h_GUI = GUICreate("TreeView Delete Item", 392, 254)

$treeview = GUICtrlCreateTreeView(10, 10, 150, 150)
$nItem2 = GUICtrlCreateTreeViewItem("Item2", $treeview)
$nItem1 = GUICtrlCreateTreeViewItem("Item1", $treeview)
$nSubItem2 = GUICtrlCreateTreeViewItem("SubItem2", $nItem1)
$nSubItem1 = GUICtrlCreateTreeViewItem("SubItem1", $nItem1)
$nSubItem3 = GUICtrlCreateTreeViewItem("SubItem3", $nSubItem1)
$nSubItem4 = GUICtrlCreateTreeViewItem("SubItem4", $nSubItem3)

$Btn_Delete = GUICtrlCreateButton("Delete Selected", 70, 170, 90, 20)
$Btn_DeleteItem = GUICtrlCreateButton("Delete SubItem4", 70, 200, 90, 20)

GUISetState()

While 1
$Msg = GUIGetMsg()
Select
Case $Msg = $GUI_EVENT_CLOSE
ExitLoop
Case $Msg = $Btn_Delete
_GUICtrlTreeViewDeleteItem ($h_GUI, $treeview)
Case $Msg = $Btn_DeleteItem
_GUICtrlTreeViewDeleteItem ($h_GUI, $treeview, $nSubItem4)
EndSelect
WEnd

Exit


Function _GUICtrlTreeViewExpand

Function Reference

_GUICtrlTreeViewExpand

Expands or collapses the list of child items associated with the specified parent item, if any.

#Include <GuiTreeView.au3>
_GUICtrlTreeViewExpand ( $i_treeview [, $i_expand = 1 [, $h_itemID = 0 ]] )

Parameters

$i_treeview | controlID
$i_expand | Optional: expand items (default 1)
$h_itemID | Optional: item ID/handle (default 0)

Return Value

None.

Remarks

None.

Related

None.

Example

#include <GuiTreeView.au3>

opt("MustDeclareVars", 1)
opt("GUIDataSeparatorChar", "\")
Dim $h_GUI, $treeview, $nItem1, $nItem2, $nItem3
Dim $nSubItem1, $nSubItem2, $nSubItem3, $nSubItem4, $nSubItem5, $nSubItem6, $nSubItem7
Dim $Btn_Expand, $Btn_ExpandItem, $Msg, $Btn_Collapse, $Btn_CollapseItem

$h_GUI = GUICreate("TreeView Expand", 392, 254)

$treeview = GUICtrlCreateTreeView(10, 10, 150, 150)
$nItem2 = GUICtrlCreateTreeViewItem("Item2", $treeview)
$nItem1 = GUICtrlCreateTreeViewItem("Item1", $treeview)
$nItem3 = GUICtrlCreateTreeViewItem("Item3", $treeview)
$nSubItem2 = GUICtrlCreateTreeViewItem("SubItem2", $nItem1)
$nSubItem1 = GUICtrlCreateTreeViewItem("SubItem1", $nItem1)
$nSubItem4 = GUICtrlCreateTreeViewItem("SubItem4", $nSubItem1)
$nSubItem5 = GUICtrlCreateTreeViewItem("SubItem5", $nSubItem4)
$nSubItem6 = GUICtrlCreateTreeViewItem("SubItem6", $nSubItem5)
$nSubItem3 = GUICtrlCreateTreeViewItem("SubItem3", $nSubItem1)
$nSubItem7 = GUICtrlCreateTreeViewItem("SubItem7", $nItem3)

$Btn_Expand = GUICtrlCreateButton("Expand All", 70, 170, 90, 20)
$Btn_Collapse = GUICtrlCreateButton("Collapse All", 200, 170, 90, 20)
$Btn_ExpandItem = GUICtrlCreateButton("Expand Item1", 70, 200, 90, 20)
$Btn_CollapseItem = GUICtrlCreateButton("Collapse Item1", 200, 200, 90, 20)

GUISetState()

While 1
$Msg = GUIGetMsg()
Select
Case $Msg = $GUI_EVENT_CLOSE
ExitLoop
Case $Msg = $Btn_Expand
_GUICtrlTreeViewExpand($treeview)
Case $Msg = $Btn_ExpandItem
_GUICtrlTreeViewExpand($treeview, 1, $nItem1)
Case $Msg = $Btn_Collapse
_GUICtrlTreeViewExpand($treeview, 0)
Case $Msg = $Btn_CollapseItem
_GUICtrlTreeViewExpand($treeview, 0, $nItem1)
EndSelect
WEnd

Exit


Function _GUICtrlTreeViewGetBkColor

Function Reference

_GUICtrlTreeViewGetBkColor

Gets the text back color of a treeview control.

#Include <GuiTreeView.au3>
_GUICtrlTreeViewGetBkColor ( $i_treeview )

Parameters

$i_treeview controlID

Return Value

Returns Hex RGB back color of the control.

Remarks

None.

Related

_GUICtrlTreeViewGetLineColor, _GUICtrlTreeViewGetTextColor, _GUICtrlTreeViewSetBkColor, _GUICtrlTreeViewSetLineColor, _GUICtrlTreeViewSetTextColor

Example

#include <WindowsConstants.au3>
#include <GuiTreeView.au3>
#include <GuiStatusBar.au3>

opt("MustDeclareVars", 1)

Global Const $Turquoise = 0x40e0d0
Global Const $Crimson = 0xDC143C
Global Const $White = 0xFFFFFF

Dim $myGui, $treeview, $generalitem, $displayitem, $aboutitem, $compitem, $useritem, $resitem, $otheritem
Dim $Status, $startlabel, $aboutlabel, $compinfo, $cancelbutton, $msg

$myGui = GUICreate("TreeView Get Back Color", 392, 254)

$treeview = GUICtrlCreateTreeView(6, 6, 100, 150, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$generalitem = GUICtrlCreateTreeViewItem("General", $treeview)
$displayitem = GUICtrlCreateTreeViewItem("Display", $treeview)
$aboutitem = GUICtrlCreateTreeViewItem("About", $generalitem)
$compitem = GUICtrlCreateTreeViewItem("Computer", $generalitem)
$useritem = GUICtrlCreateTreeViewItem("User", $generalitem)
$resitem = GUICtrlCreateTreeViewItem("Resolution", $displayitem)
$otheritem = GUICtrlCreateTreeViewItem("Other", $displayitem)
$Status = _GuiCtrlStatusBarCreate($myGui, -1, "")
_GuiCtrlStatusBarSetSimple($Status)

$startlabel = GUICtrlCreateLabel("TreeView Demo", 190, 90, 100, 20)
$aboutlabel = GUICtrlCreateLabel("This little scripts demonstates the using of a treeview-control.", 190, 70, 100, 60)
GUICtrlSetState(-1, $GUI_HIDE)
$compinfo = GUICtrlCreateLabel("Name:" & @TAB & @ComputerName & @LF & "OS:" & @TAB & @OSVersion & @LF & "SP:" & @TAB & @OSServicePack, 120, 30, 200, 80)
GUICtrlSetState(-1, $GUI_HIDE)

$cancelbutton = GUICtrlCreateButton("Cancel", 180, 185, 70, 20)

_GUICtrlTreeViewSetBkColor ($treeview, $Turquoise)
_GUICtrlTreeViewSetTextColor ($treeview, $Crimson)
_GUICtrlTreeViewSetLineColor ($treeview, $White)

GUISetState()
_GuiCtrlStatusBarSetText($Status,"Hex RGB Treeview Back Color: " & _GUICtrlTreeViewGetBkColor ($treeview),255)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $cancelbutton Or $msg = $GUI_EVENT_CLOSE
ExitLoop

Case $msg = $generalitem
GUIChangeItems($aboutlabel, $compinfo, $startlabel, $startlabel)

Case $msg = $aboutitem
GUICtrlSetState($compinfo, $GUI_HIDE)
GUIChangeItems($startlabel, $startlabel, $aboutlabel, $aboutlabel)

Case $msg = $compitem
GUIChangeItems($startlabel, $aboutlabel, $compinfo, $compinfo)

EndSelect
WEnd

GUIDelete()
Exit

Func GUIChangeItems($hidestart, $hideend, $showstart, $showend)
Local $idx

For $idx = $hidestart To $hideend
GUICtrlSetState($idx, $GUI_HIDE)
Next
For $idx = $showstart To $showend
GUICtrlSetState($idx, $GUI_SHOW)
Next
EndFunc ;==>GUIChangeItems


Function _GUICtrlTreeViewGetCount

Function Reference

_GUICtrlTreeViewGetCount

Retrieves a count of the items in a treeview control.

#Include <GuiTreeView.au3>
_GUICtrlTreeViewGetCount ( $i_treeview )

Parameters

$i_treeview controlID

Return Value

Returns the count of items.

Remarks

None.

Related

None.

Example

#include <WindowsConstants.au3>
#include <GuiTreeView.au3>
#include <GuiStatusBar.au3>

opt("MustDeclareVars", 1)

Dim $myGui, $treeview, $generalitem, $displayitem, $aboutitem
Dim $compitem, $useritem, $resitem, $otheritem, $Status, $startlabel, $aboutlabel
Dim $compinfo, $msg, $cancelbutton

Global Const $Turquoise = 0x40e0d0
Global Const $Crimson = 0xDC143C
Global Const $White = 0xFFFFFF

$myGui = GUICreate("TreeView Get Count", 392, 254)

$treeview = GUICtrlCreateTreeView(6, 6, 100, 150, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$generalitem = GUICtrlCreateTreeViewItem("General", $treeview)
$displayitem = GUICtrlCreateTreeViewItem("Display", $treeview)
$aboutitem = GUICtrlCreateTreeViewItem("About", $generalitem)
$compitem = GUICtrlCreateTreeViewItem("Computer", $generalitem)
$useritem = GUICtrlCreateTreeViewItem("User", $generalitem)
$resitem = GUICtrlCreateTreeViewItem("Resolution", $displayitem)
$otheritem = GUICtrlCreateTreeViewItem("Other", $displayitem)
$Status = _GuiCtrlStatusBarCreate($myGui, -1, "")
_GuiCtrlStatusBarSetSimple($Status)

$startlabel = GUICtrlCreateLabel("TreeView Demo", 190, 90, 100, 20)
$aboutlabel = GUICtrlCreateLabel("This little scripts demonstates the using of a treeview-control.", 190, 70, 100, 60)
GUICtrlSetState(-1, $GUI_HIDE)
$compinfo = GUICtrlCreateLabel("Name:" & @TAB & @ComputerName & @LF & "OS:" & @TAB & @OSVersion & @LF & "SP:" & @TAB & @OSServicePack, 120, 30, 200, 80)
GUICtrlSetState(-1, $GUI_HIDE)

$cancelbutton = GUICtrlCreateButton("Cancel", 180, 185, 70, 20)

_GUICtrlTreeViewSetBkColor ($treeview, $Turquoise)
_GUICtrlTreeViewSetTextColor ($treeview, $Crimson)
_GUICtrlTreeViewSetLineColor ($treeview, $White)

GUISetState()
_GuiCtrlStatusBarSetText($Status,"Number Of Items: " & _GUICtrlTreeViewGetCount ($treeview),255)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $cancelbutton Or $msg = $GUI_EVENT_CLOSE
ExitLoop

Case $msg = $generalitem
GUIChangeItems($aboutlabel, $compinfo, $startlabel, $startlabel)

Case $msg = $aboutitem
GUICtrlSetState($compinfo, $GUI_HIDE)
GUIChangeItems($startlabel, $startlabel, $aboutlabel, $aboutlabel)

Case $msg = $compitem
GUIChangeItems($startlabel, $aboutlabel, $compinfo, $compinfo)

EndSelect
WEnd

GUIDelete()
Exit

Func GUIChangeItems($hidestart, $hideend, $showstart, $showend)
Local $idx

For $idx = $hidestart To $hideend
GUICtrlSetState($idx, $GUI_HIDE)
Next
For $idx = $showstart To $showend
GUICtrlSetState($idx, $GUI_SHOW)
Next
EndFunc ;==>GUIChangeItems


Function _GUICtrlTreeViewGetIndent

Function Reference

_GUICtrlTreeViewGetIndent

Retrieves the amount in pixels, that child items are indented relative to their parent items.

#Include <GuiTreeView.au3>
_GUICtrlTreeViewGetIndent ( $i_treeview )

Parameters

$i_treeview controlID

Return Value

Returns the amount of indentation.

Remarks

None.

Related

_GUICtrlTreeViewSetIndent

Example

#include <WindowsConstants.au3>
#include <GuiTreeView.au3>
#include <GuiStatusBar.au3>

opt("MustDeclareVars", 1)

Global Const $Turquoise = 0x40e0d0
Global Const $Crimson = 0xDC143C
Global Const $White = 0xFFFFFF

Dim $myGui, $treeview, $generalitem, $displayitem, $aboutitem
Dim $compitem, $useritem, $resitem, $otheritem, $Status, $startlabel, $aboutlabel
Dim $compinfo, $msg, $cancelbutton

$myGui = GUICreate("TreeView Get Indent", 392, 254)

$treeview = GUICtrlCreateTreeView(6, 6, 100, 150, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$generalitem = GUICtrlCreateTreeViewItem("General", $treeview)
$displayitem = GUICtrlCreateTreeViewItem("Display", $treeview)
$aboutitem = GUICtrlCreateTreeViewItem("About", $generalitem)
$compitem = GUICtrlCreateTreeViewItem("Computer", $generalitem)
$useritem = GUICtrlCreateTreeViewItem("User", $generalitem)
$resitem = GUICtrlCreateTreeViewItem("Resolution", $displayitem)
$otheritem = GUICtrlCreateTreeViewItem("Other", $displayitem)
$Status = _GuiCtrlStatusBarCreate($myGui, -1, "")
_GuiCtrlStatusBarSetSimple($Status)

$startlabel = GUICtrlCreateLabel("TreeView Demo", 190, 90, 100, 20)
$aboutlabel = GUICtrlCreateLabel("This little scripts demonstates the using of a treeview-control.", 190, 70, 100, 60)
GUICtrlSetState(-1, $GUI_HIDE)
$compinfo = GUICtrlCreateLabel("Name:" & @TAB & @ComputerName & @LF & "OS:" & @TAB & @OSVersion & @LF & "SP:" & @TAB & @OSServicePack, 120, 30, 200, 80)
GUICtrlSetState(-1, $GUI_HIDE)

$cancelbutton = GUICtrlCreateButton("Cancel", 180, 185, 70, 20)

_GUICtrlTreeViewSetBkColor ($treeview, $Turquoise)
_GUICtrlTreeViewSetTextColor ($treeview, $Crimson)
_GUICtrlTreeViewSetLineColor ($treeview, $White)

GUISetState()
_GuiCtrlStatusBarSetText($Status,"Indent: " & _GUICtrlTreeViewGetIndent ($treeview) & " in pixels",255)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $cancelbutton Or $msg = $GUI_EVENT_CLOSE
ExitLoop

Case $msg = $generalitem
GUIChangeItems($aboutlabel, $compinfo, $startlabel, $startlabel)

Case $msg = $aboutitem
GUICtrlSetState($compinfo, $GUI_HIDE)
GUIChangeItems($startlabel, $startlabel, $aboutlabel, $aboutlabel)

Case $msg = $compitem
GUIChangeItems($startlabel, $aboutlabel, $compinfo, $compinfo)

EndSelect
WEnd

GUIDelete()
Exit

Func GUIChangeItems($hidestart, $hideend, $showstart, $showend)
Local $idx

For $idx = $hidestart To $hideend
GUICtrlSetState($idx, $GUI_HIDE)
Next
For $idx = $showstart To $showend
GUICtrlSetState($idx, $GUI_SHOW)
Next
EndFunc ;==>GUIChangeItems


Function _GUICtrlTreeViewGetLineColor

Function Reference

_GUICtrlTreeViewGetLineColor

Gets the line color of a treeview control.

#Include <GuiTreeView.au3>
_GUICtrlTreeViewGetLineColor ( $i_treeview )

Parameters

$i_treeview controlID

Return Value

Returns Hex RGB line color of the control.

Remarks

None.

Related

_GUICtrlTreeViewGetBkColor, _GUICtrlTreeViewGetTextColor, _GUICtrlTreeViewSetBkColor, _GUICtrlTreeViewSetLineColor, _GUICtrlTreeViewSetTextColor

Example

#include <WindowsConstants.au3>
#include <GuiTreeView.au3>
#include <GuiStatusBar.au3>

opt("MustDeclareVars", 1)

Global Const $Turquoise = 0x40e0d0
Global Const $Crimson = 0xDC143C
Global Const $White = 0xFFFFFF

Dim $myGui, $treeview, $generalitem, $displayitem, $aboutitem
Dim $compitem, $useritem, $resitem, $otheritem, $Status, $startlabel, $aboutlabel
Dim $compinfo, $msg, $cancelbutton

$myGui = GUICreate("TreeView Get Line Color", 392, 254)

$treeview = GUICtrlCreateTreeView(6, 6, 100, 150, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$generalitem = GUICtrlCreateTreeViewItem("General", $treeview)
$displayitem = GUICtrlCreateTreeViewItem("Display", $treeview)
$aboutitem = GUICtrlCreateTreeViewItem("About", $generalitem)
$compitem = GUICtrlCreateTreeViewItem("Computer", $generalitem)
$useritem = GUICtrlCreateTreeViewItem("User", $generalitem)
$resitem = GUICtrlCreateTreeViewItem("Resolution", $displayitem)
$otheritem = GUICtrlCreateTreeViewItem("Other", $displayitem)
$Status = _GuiCtrlStatusBarCreate($myGui, -1, "")
_GuiCtrlStatusBarSetSimple($Status)

$startlabel = GUICtrlCreateLabel("TreeView Demo", 190, 90, 100, 20)
$aboutlabel = GUICtrlCreateLabel("This little scripts demonstates the using of a treeview-control.", 190, 70, 100, 60)
GUICtrlSetState(-1, $GUI_HIDE)
$compinfo = GUICtrlCreateLabel("Name:" & @TAB & @ComputerName & @LF & "OS:" & @TAB & @OSVersion & @LF & "SP:" & @TAB & @OSServicePack, 120, 30, 200, 80)
GUICtrlSetState(-1, $GUI_HIDE)

$cancelbutton = GUICtrlCreateButton("Cancel", 180, 185, 70, 20)

_GUICtrlTreeViewSetBkColor ($treeview, $Turquoise)
_GUICtrlTreeViewSetTextColor ($treeview, $Crimson)
_GUICtrlTreeViewSetLineColor ($treeview, $White)

GUISetState()
_GuiCtrlStatusBarSetText($Status,"Hex RGB Treeview Line Color: " & _GUICtrlTreeViewGetLineColor ($treeview),255)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $cancelbutton Or $msg = $GUI_EVENT_CLOSE
ExitLoop

Case $msg = $generalitem
GUIChangeItems($aboutlabel, $compinfo, $startlabel, $startlabel)

Case $msg = $aboutitem
GUICtrlSetState($compinfo, $GUI_HIDE)
GUIChangeItems($startlabel, $startlabel, $aboutlabel, $aboutlabel)

Case $msg = $compitem
GUIChangeItems($startlabel, $aboutlabel, $compinfo, $compinfo)

EndSelect
WEnd

GUIDelete()
Exit

Func GUIChangeItems($hidestart, $hideend, $showstart, $showend)
Local $idx

For $idx = $hidestart To $hideend
GUICtrlSetState($idx, $GUI_HIDE)
Next
For $idx = $showstart To $showend
GUICtrlSetState($idx, $GUI_SHOW)
Next
EndFunc ;==>GUIChangeItems


Function _GUICtrlTreeViewGetParentHandle

Function Reference

_GUICtrlTreeViewGetParentHandle

Gets the parent handle of item selected (default) or any specified item in treeview control.

#Include <GuiTreeView.au3>
_GUICtrlTreeViewGetParentHandle ( $i_treeview [, $h_itemID = 0 ] )

Parameters

$i_treeview | controlID
$h_itemID | Optional: specified item ID/handle to get the parent of (default 0)

Return Value

Returns the parent handle.

Remarks

None.

Related

None.

Example

#include <GuiTreeView.au3>
#include <GuiStatusBar.au3>

opt ("MustDeclareVars", 1)

Dim $tree, $item1, $subitem1, $subitem2, $item2, $subitem3, $subitem4, $button, $msg, $Status, $gui

$gui = GUICreate("Test", 392, 254)
$tree = GUICtrlCreateTreeView(10, 10, 200, 200)

$item1 = GUICtrlCreateTreeViewItem("Mainitem1", $tree)
$subitem1 = GUICtrlCreateTreeViewItem("Subitem11", $item1)
$subitem2 = GUICtrlCreateTreeViewItem("Subitem12", $item1)
$item2 = GUICtrlCreateTreeViewItem("Mainitem2", $tree)
$subitem3 = GUICtrlCreateTreeViewItem("Subitem21", $item2)
$subitem4 = GUICtrlCreateTreeViewItem("Subitem22", $item2)

$button = GUICtrlCreateButton("Check", 220, 100, 70, 20)
$Status = _GuiCtrlStatusBarCreate($gui, -1, "")
_GuiCtrlStatusBarSetSimple($Status)

GUISetState()

While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
_GuiCtrlStatusBarSetText($Status, "Parent Handle: " & _GUICtrlTreeViewGetParentHandle ($tree),255)
EndSelect
WEnd

Exit


Function _GUICtrlTreeViewGetParentID

Function Reference

_GUICtrlTreeViewGetParentID

Gets the parent control ID of item selected (default) or any specified item in treeview control.

#Include <GuiTreeView.au3>
_GUICtrlTreeViewGetParentID ( $i_treeview [, $h_itemID = 0 ] )

Parameters

$i_treeview | controlID
$h_itemID | Optional: specified item ID/handle to get the parent of (default 0)

Return Value

Returns the parent control ID.

Remarks

None.

Related

None.

Example

#include <GuiTreeView.au3>
#include <GuiStatusBar.au3>
opt("MustDeclareVars", 1)

Dim $tree, $item1, $subitem1, $subitem2, $item2, $subitem3, $subitem4, $button, $msg, $Status, $gui
$gui = GUICreate("GuiTreeView Get Parent ID", 392, 254)
$tree = GUICtrlCreateTreeView(10, 10, 200, 200)
$item1 = GUICtrlCreateTreeViewItem("Mainitem1", $tree)
$subitem1 = GUICtrlCreateTreeViewItem("Subitem11", $item1)
$subitem2 = GUICtrlCreateTreeViewItem("Subitem12", $item1)
$item2 = GUICtrlCreateTreeViewItem("Mainitem2", $tree)
$subitem3 = GUICtrlCreateTreeViewItem("Subitem21", $item2)
$subitem4 = GUICtrlCreateTreeViewItem("Subitem22", $item2)
$button = GUICtrlCreateButton("Check", 220, 100, 70, 20)
$Status = _GuiCtrlStatusBarCreate($gui, -1, "")
_GuiCtrlStatusBarSetSimple($Status)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button
_GuiCtrlStatusBarSetText($Status, "Parent Text: " & GUICtrlRead(_GUICtrlTreeViewGetParentID ($tree), 1),255)
EndSelect
WEnd
Exit


Function _GUICtrlTreeViewGetState

Function Reference

_GUICtrlTreeViewGetState

Returns the state of the specified treeview item.

#Include <GuiTreeView.au3>
_GUICtrlTreeViewGetState ( $i_treeview, $h_item )

Parameters

$i_treeview | controlID
$h_item | item ID/handle to get the state of

Return Value

Success: Returns the state of the item (See Remarks).
Failure: Returns 0.

Remarks

State table
State | Value
$TVIS_SELECTED | 2
$TVIS_CUT | 4
$TVIS_DROPHILITED | 8
$TVIS_BOLD | 16
$TVIS_EXPANDED | 32
$TVIS_EXPANDEDONCE | 64
$TVIS_EXPANDPARTIAL | 128

Related

_GUICtrlTreeViewSetState

Example

#include <WindowsConstants.au3>
#include <GuiTreeView.au3>

Opt("MustDeclareVars", 1)
Opt("GUIDataSeparatorChar", "\")

Dim $h_GUI, $Msg, $treeview
Dim $h_root1, $h_root2, $h_root3, $h_tmp
Dim $n_btn_getstate

$h_GUI = GUICreate("TreeView UDF Sample", 220, 250)

$treeview = GUICtrlCreateTreeView(10, 10, 200, 200, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetImage(-1, "shell32.dll", 3, 4)
GUICtrlSetImage(-1, "shell32.dll", 4, 2)

$h_root1 = _GUICtrlTreeViewInsertItem($treeview, "RootItem1")
_GUICtrlTreeViewSetIcon($treeview, $h_root1, "shell32.dll", 7)

_GUICtrlTreeViewInsertItem($treeview, "SubItem1", $h_root1)
_GUICtrlTreeViewInsertItem($treeview, "SubItem2", $h_root1)

$h_root2 = _GUICtrlTreeViewInsertItem($treeview, "RootItem2")
_GUICtrlTreeViewSetIcon($treeview, $h_root2, "shell32.dll", 12)

$h_root3 = _GUICtrlTreeViewInsertItem($treeview, "RootItem3")
_GUICtrlTreeViewInsertItem($treeview, "SubItem3", $h_root3)
_GUICtrlTreeViewInsertItem($treeview, "SubItem4", $h_root3)

$n_btn_getstate = GUICtrlCreateButton("Get RootItem2 State", 10, 220, 200, 20)

GUISetState()

While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
ExitLoop

Case $n_btn_getstate
Msgbox(0, "State", _GUICtrlTreeViewGetState($treeview, $h_root2))
EndSwitch
WEnd

Exit


Function _GUICtrlTreeViewGetText

Function Reference

_GUICtrlTreeViewGetText

Returns the text of the specified treeview item.

#Include <GuiTreeView.au3>
_GUICtrlTreeViewGetText ( $i_treeview, $h_item )

Parameters

$i_treeview | controlID
$h_item | item ID/handle to get the text of

Return Value

Success: Returns the text of the item.
Failure: Returns an empty string.

Remarks

None.

Related

None.

Example

#include <WindowsConstants.au3>
#include <GuiTreeView.au3>
#include <GuiStatusBar.au3>

Opt("MustDeclareVars", 1)

Dim $h_GUI, $Msg, $treeview
Dim $h_root1, $h_root2, $h_root3, $h_item
Dim $n_btn_gettext, $Status

$h_GUI = GUICreate("TreeView UDF Sample", 220, 250)

$treeview = GUICtrlCreateTreeView(10, 10, 200, 180, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetImage(-1, "shell32.dll", 3, 4)
GUICtrlSetImage(-1, "shell32.dll", 4, 2)

$h_root1 = _GUICtrlTreeViewInsertItem($treeview, "RootItem1")
_GUICtrlTreeViewSetIcon($treeview, $h_root1, "shell32.dll", 7)

_GUICtrlTreeViewInsertItem($treeview, "SubItem1", $h_root1)
_GUICtrlTreeViewInsertItem($treeview, "SubItem2", $h_root1)

$h_root2 = _GUICtrlTreeViewInsertItem($treeview, "RootItem2")
_GUICtrlTreeViewSetIcon($treeview, $h_root2, "shell32.dll", 12)

$h_root3 = _GUICtrlTreeViewInsertItem($treeview, "RootItem3")
_GUICtrlTreeViewInsertItem($treeview, "SubItem3", $h_root3)
_GUICtrlTreeViewInsertItem($treeview, "SubItem4", $h_root3)

$n_btn_gettext = GUICtrlCreateButton("Get text", 10, 200, 200, 20)

$Status = _GuiCtrlStatusBarCreate($h_GUI, -1, "")
_GuiCtrlStatusBarSetSimple($Status)

GUISetState()

While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
ExitLoop

Case $n_btn_gettext
$h_item = GUICtrlSendMsg($treeview, $TVM_GETNEXTITEM, $TVGN_CARET, 0)
If $h_item > 0 Then _GuiCtrlStatusBarSetText($Status,"Get Text: " & _GUICtrlTreeViewGetText($treeview, $h_item),255)
EndSwitch
WEnd

Exit


Function _GUICtrlTreeViewGetTextColor

Function Reference

_GUICtrlTreeViewGetTextColor

Gets the text color of a treeview control.

#Include <GuiTreeView.au3>
_GUICtrlTreeViewGetTextColor ( $i_treeview )

Parameters

$i_treeview controlID

Return Value

Returns Hex RGB text color of the control.

Remarks

None.

Related

_GUICtrlTreeViewGetBkColor, _GUICtrlTreeViewGetLineColor, _GUICtrlTreeViewSetBkColor, _GUICtrlTreeViewSetLineColor, _GUICtrlTreeViewSetTextColor

Example

#include <WindowsConstants.au3>
#include <GuiTreeView.au3>
#include <GuiStatusBar.au3>

opt("MustDeclareVars", 1)

Global Const $Turquoise = 0x40e0d0
Global Const $Crimson = 0xDC143C
Global Const $White = 0xFFFFFF

Dim $myGui, $treeview, $generalitem, $displayitem, $aboutitem
Dim $compitem, $useritem, $resitem, $otheritem, $Status, $startlabel, $aboutlabel
Dim $compinfo, $msg, $cancelbutton

$myGui = GUICreate("TreeView Get Text Color", 392, 254)

$treeview = GUICtrlCreateTreeView(6, 6, 100, 150, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$generalitem = GUICtrlCreateTreeViewItem("General", $treeview)
$displayitem = GUICtrlCreateTreeViewItem("Display", $treeview)
$aboutitem = GUICtrlCreateTreeViewItem("About", $generalitem)
$compitem = GUICtrlCreateTreeViewItem("Computer", $generalitem)
$useritem = GUICtrlCreateTreeViewItem("User", $generalitem)
$resitem = GUICtrlCreateTreeViewItem("Resolution", $displayitem)
$otheritem = GUICtrlCreateTreeViewItem("Other", $displayitem)
$Status = _GuiCtrlStatusBarCreate($myGui, -1, "")
_GuiCtrlStatusBarSetSimple($Status)

$startlabel = GUICtrlCreateLabel("TreeView Demo", 190, 90, 100, 20)
$aboutlabel = GUICtrlCreateLabel("This little scripts demonstates the using of a treeview-control.", 190, 70, 100, 60)
GUICtrlSetState(-1, $GUI_HIDE)
$compinfo = GUICtrlCreateLabel("Name:" & @TAB & @ComputerName & @LF & "OS:" & @TAB & @OSVersion & @LF & "SP:" & @TAB & @OSServicePack, 120, 30, 200, 80)
GUICtrlSetState(-1, $GUI_HIDE)

$cancelbutton = GUICtrlCreateButton("Cancel", 180, 185, 70, 20)

_GUICtrlTreeViewSetBkColor ($treeview, $Turquoise)
_GUICtrlTreeViewSetTextColor ($treeview, $Crimson)
_GUICtrlTreeViewSetLineColor ($treeview, $White)

GUISetState()
_GuiCtrlStatusBarSetText($Status,"Hex RGB Treeview Text Color: " & _GUICtrlTreeViewGetTextColor ($treeview),255)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $cancelbutton Or $msg = $GUI_EVENT_CLOSE
ExitLoop

Case $msg = $generalitem
GUIChangeItems($aboutlabel, $compinfo, $startlabel, $startlabel)

Case $msg = $aboutitem
GUICtrlSetState($compinfo, $GUI_HIDE)
GUIChangeItems($startlabel, $startlabel, $aboutlabel, $aboutlabel)

Case $msg = $compitem
GUIChangeItems($startlabel, $aboutlabel, $compinfo, $compinfo)

EndSelect
WEnd

GUIDelete()
Exit

Func GUIChangeItems($hidestart, $hideend, $showstart, $showend)
Local $idx

For $idx = $hidestart To $hideend
GUICtrlSetState($idx, $GUI_HIDE)
Next
For $idx = $showstart To $showend
GUICtrlSetState($idx, $GUI_SHOW)
Next
EndFunc ;==>GUIChangeItems


Function _GUICtrlTreeViewGetTree

Function Reference

_GUICtrlTreeViewGetTree

Get all items text beginning by the current selected item from the treeview control.

#Include <GuiTreeView.au3>
_GUICtrlTreeViewGetTree ( $i_treeview, $s_sep_char )

Parameters

$i_treeview | controlID
$s_sep_char | character used for path seperator

Return Value

Success: Returns the Tree Path of the selected item.
Failure: Returns an empty string (i.e. no item is currently selected).

Remarks

None.

Related

None.

Example

#include <WindowsConstants.au3>
#include <GuiTreeView.au3>
#include <GuiStatusBar.au3>

opt("MustDeclareVars", 1)

Global Const $Turquoise = 0x40e0d0
Global Const $Crimson = 0xDC143C
Global Const $White = 0xFFFFFF

Dim $hGUI, $treeview, $nItem1, $nItem2, $nItem3
Dim $nSubItem1, $nSubItem2, $nSubItem3, $nSubItem4
Dim $nButton, $Status, $nMsg

$hGUI = GUICreate("TreeView Item Get Tree", 392, 254)

$treeview = GUICtrlCreateTreeView(10, 10, 150, 150)
$nItem2 = GUICtrlCreateTreeViewItem("Item2", $treeview)
$nItem1 = GUICtrlCreateTreeViewItem("Item1", $treeview)
$nSubItem2 = GUICtrlCreateTreeViewItem("SubItem2", $nItem1)
$nSubItem1 = GUICtrlCreateTreeViewItem("SubItem1", $nItem1)
$nSubItem4 = GUICtrlCreateTreeViewItem("SubItem4", $nSubItem1)
$nSubItem3 = GUICtrlCreateTreeViewItem("SubItem3", $nSubItem1)

$nButton = GUICtrlCreateButton("Path?", 70, 170, 70, 20)
$Status = _GuiCtrlStatusBarCreate($hGUI, -1, "")
_GuiCtrlStatusBarSetSimple($Status)

_GUICtrlTreeViewSetBkColor($treeview, $Turquoise)
_GUICtrlTreeViewSetTextColor($treeview, $Crimson)
_GUICtrlTreeViewSetLineColor($treeview, $White)
_GUICtrlTreeViewSetIndent($treeview, 30)

GUISetState()

While 1
$nMsg = GUIGetMsg()
Select
Case $nMsg = $GUI_EVENT_CLOSE
ExitLoop
Case $nMsg = $nButton
_GuiCtrlStatusBarSetText($Status,"Path: " & _GUICtrlTreeViewGetTree($treeview, "\"),255)
EndSelect
WEnd

Exit


Function _GUICtrlTreeViewInsertItem

Function Reference

_GUICtrlTreeViewInsertItem

Insert a new item into a treeview control.

#Include <GuiTreeView.au3>
_GUICtrlTreeViewInsertItem ( $i_treeview, $s_itemtext [, $h_item [, $h_item_after ]] )

Parameters

$i_treeview | controlID
$s_itemtext | item text
$h_item | Optional: parent item handle (default $TVI_ROOT)
$h_item_after | Optional: item handle to insert new item after (default $TVI_LAST)

Return Value

Success: Returns the handle to the new inserted item.
Failure: Returns 0.

Remarks

None.

Related

None.

Example

#include <WindowsConstants.au3>
#include <GuiTreeView.au3>

Opt("MustDeclareVars", 1)

Dim $h_GUI, $Msg, $treeview
Dim $h_root1, $h_root2, $h_root3
Dim $n_btn_insert

$h_GUI = GUICreate("TreeView UDF Sample", 220, 250)

$treeview = GUICtrlCreateTreeView(10, 10, 200, 200, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetImage(-1, "shell32.dll", 3, 4)
GUICtrlSetImage(-1, "shell32.dll", 4, 2)

$h_root1 = _GUICtrlTreeViewInsertItem($treeview, "RootItem1")
_GUICtrlTreeViewInsertItem($treeview, "SubItem1", $h_root1)
_GUICtrlTreeViewInsertItem($treeview, "SubItem2", $h_root1)

$h_root2 = _GUICtrlTreeViewInsertItem($treeview, "RootItem2")

$h_root3 = _GUICtrlTreeViewInsertItem($treeview, "RootItem3")
_GUICtrlTreeViewInsertItem($treeview, "SubItem3", $h_root3)
_GUICtrlTreeViewInsertItem($treeview, "SubItem4", $h_root3)

$n_btn_insert = GUICtrlCreateButton("Insert Items", 10, 220, 200, 20)

GUISetState()

While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
ExitLoop

Case $n_btn_insert
GUICtrlSetCursor($treeview, 1)
For $i = 3 To 500
_GUICtrlTreeViewInsertItem($treeview, "RootItem" & $i)
ToolTip((500 - $i) & " items are created...")
Next
ToolTip("")
GUICtrlSetCursor($treeview, 2)
EndSwitch
WEnd

Exit


Function _GUICtrlTreeViewSetBkColor

Function Reference

_GUICtrlTreeViewSetBkColor

Sets the back color of a treeview control.

#Include <GuiTreeView.au3>
_GUICtrlTreeViewSetBkColor ( $i_treeview, $v_RGBcolor )

Parameters

$i_treeview | controlID
$v_RGBcolor | New Hex text color

Return Value

Returns the previous Hex RGB Back Color of treeview.

Remarks

None.

Related

_GUICtrlTreeViewGetBkColor, _GUICtrlTreeViewGetLineColor, _GUICtrlTreeViewGetTextColor, _GUICtrlTreeViewSetLineColor, _GUICtrlTreeViewSetTextColor

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <GuiStatusBar.au3>

opt("MustDeclareVars", 1)

Global Const $Turquoise = 0x40e0d0
Global Const $Crimson = 0xDC143C
Global Const $White = 0xFFFFFF

Dim $myGui, $treeview, $generalitem, $displayitem, $aboutitem
Dim $compitem, $useritem, $resitem, $otheritem, $Status, $startlabel, $aboutlabel
Dim $compinfo, $msg, $cancelbutton

$myGui = GUICreate("TreeView Set Back Color", 392, 254)

$treeview = GUICtrlCreateTreeView(6, 6, 100, 150, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$generalitem = GUICtrlCreateTreeViewItem("General", $treeview)
$displayitem = GUICtrlCreateTreeViewItem("Display", $treeview)
$aboutitem = GUICtrlCreateTreeViewItem("About", $generalitem)
$compitem = GUICtrlCreateTreeViewItem("Computer", $generalitem)
$useritem = GUICtrlCreateTreeViewItem("User", $generalitem)
$resitem = GUICtrlCreateTreeViewItem("Resolution", $displayitem)
$otheritem = GUICtrlCreateTreeViewItem("Other", $displayitem)
$Status = _GuiCtrlStatusBarCreate($myGui, -1, "")
_GuiCtrlStatusBarSetSimple($Status)

$startlabel = GUICtrlCreateLabel("TreeView Demo", 190, 90, 100, 20)
$aboutlabel = GUICtrlCreateLabel("This little scripts demonstates the using of a treeview-control.", 190, 70, 100, 60)
GUICtrlSetState(-1, $GUI_HIDE)
$compinfo = GUICtrlCreateLabel("Name:" & @TAB & @ComputerName & @LF & "OS:" & @TAB & @OSVersion & @LF & "SP:" & @TAB & @OSServicePack, 120, 30, 200, 80)
GUICtrlSetState(-1, $GUI_HIDE)

$cancelbutton = GUICtrlCreateButton("Cancel", 180, 185, 70, 20)

_GuiCtrlStatusBarSetText($Status,"Previous Hex RGB Treeview Back Color: " & _GUICtrlTreeViewSetBkColor ($treeview, $Turquoise),255)
_GUICtrlTreeViewSetTextColor ($treeview, $Crimson)
_GUICtrlTreeViewSetLineColor ($treeview, $White)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $cancelbutton Or $msg = $GUI_EVENT_CLOSE
ExitLoop

Case $msg = $generalitem
GUIChangeItems($aboutlabel, $compinfo, $startlabel, $startlabel)

Case $msg = $aboutitem
GUICtrlSetState($compinfo, $GUI_HIDE)
GUIChangeItems($startlabel, $startlabel, $aboutlabel, $aboutlabel)

Case $msg = $compitem
GUIChangeItems($startlabel, $aboutlabel, $compinfo, $compinfo)

EndSelect
WEnd

GUIDelete()
Exit

Func GUIChangeItems($hidestart, $hideend, $showstart, $showend)
Local $idx

For $idx = $hidestart To $hideend
GUICtrlSetState($idx, $GUI_HIDE)
Next
For $idx = $showstart To $showend
GUICtrlSetState($idx, $GUI_SHOW)
Next
EndFunc ;==>GUIChangeItems


Function _GUICtrlTreeViewSetIcon

Function Reference

_GUICtrlTreeViewSetIcon

Set an icon of the specified treeview item.

#Include <GuiTreeView.au3>
_GUICtrlTreeViewSetIcon ( $i_treeview, $h_item, $s_iconfile = "" [, $i_iconID = 0 [, $u_imagemode = 6 ]] )

Parameters

$i_treeview | controlID
$h_item | item ID/handle to set the icon for
$s_iconfile | the file to extract the icon of
$i_iconID | the iconID to extract of the file
$u_imagemode | Optional: 2=normal image / 4=seletected image to set (default 6)

Return Value

Success: Returns TRUE.
Failure: Returns FALSE.

Remarks

At first use all items of the parent treeview will change to this icon if they have none! (See Example).

Related

None.

Example

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiTreeView.au3>

Opt("MustDeclareVars", 1)

Dim $h_GUI, $Msg, $treeview
Dim $h_root1, $h_root2, $h_root3
Dim $n_btn_seticon

$h_GUI = GUICreate("TreeView UDF Sample", 220, 340)

$treeview = GUICtrlCreateTreeView(10, 10, 200, 200, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetImage(-1, "shell32.dll", 3, 4)
GUICtrlSetImage(-1, "shell32.dll", 4, 2)

$h_root1 = _GUICtrlTreeViewInsertItem($treeview, "RootItem1")
_GUICtrlTreeViewSetIcon($treeview, $h_root1, "shell32.dll", 7)

$h_root2 = _GUICtrlTreeViewInsertItem($treeview, "RootItem2")
_GUICtrlTreeViewSetIcon($treeview, $h_root2, "shell32.dll", 12)

$h_root3 = _GUICtrlTreeViewInsertItem($treeview, "RootItem3")

$n_btn_seticon = GUICtrlCreateButton("Set Random Icons", 10, 220, 200, 20)

GUISetState()

While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
ExitLoop

Case $n_btn_seticon
_GUICtrlTreeViewSetIcon($treeview, $h_root1, "shell32.dll", Random(0, 50, 1))
_GUICtrlTreeViewSetIcon($treeview, $h_root2, "shell32.dll", Random(0, 50, 1))
EndSwitch
WEnd

Exit


Function _GUICtrlTreeViewSetIndent

Function Reference

_GUICtrlTreeViewSetIndent

Sets the width of indentation for a treeview control and redraws the control to reflect the new width.

#Include <GuiTreeView.au3>
_GUICtrlTreeViewSetIndent ( $i_treeview, $i_indent )

Parameters

$i_treeview | controlID
$i_indent | Width, in pixels, of the indentation.

Return Value

None.

Remarks

$i_indent
If this parameter is less than the system-defined minimum width,
the new width is set to the system-defined minimum.

Related

_GUICtrlTreeViewGetIndent

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <GuiStatusBar.au3>

opt("MustDeclareVars", 1)

Global Const $Turquoise = 0x40e0d0
Global Const $Crimson = 0xDC143C
Global Const $White = 0xFFFFFF

Dim $myGui, $treeview, $generalitem, $displayitem, $aboutitem
Dim $compitem, $useritem, $resitem, $otheritem, $Status, $startlabel, $aboutlabel
Dim $compinfo, $msg, $cancelbutton

$myGui = GUICreate("TreeView Set Indent", 392, 254)

$treeview = GUICtrlCreateTreeView(6, 6, 100, 150, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$generalitem = GUICtrlCreateTreeViewItem("General", $treeview)
$displayitem = GUICtrlCreateTreeViewItem("Display", $treeview)
$aboutitem = GUICtrlCreateTreeViewItem("About", $generalitem)
$compitem = GUICtrlCreateTreeViewItem("Computer", $generalitem)
$useritem = GUICtrlCreateTreeViewItem("User", $generalitem)
$resitem = GUICtrlCreateTreeViewItem("Resolution", $displayitem)
$otheritem = GUICtrlCreateTreeViewItem("Other", $displayitem)
$Status = _GuiCtrlStatusBarCreate($myGui, -1, "")
_GuiCtrlStatusBarSetSimple($Status)

$startlabel = GUICtrlCreateLabel("TreeView Demo", 190, 90, 100, 20)
$aboutlabel = GUICtrlCreateLabel("This little scripts demonstates the using of a treeview-control.", 190, 70, 100, 60)
GUICtrlSetState(-1, $GUI_HIDE)
$compinfo = GUICtrlCreateLabel("Name:" & @TAB & @ComputerName & @LF & "OS:" & @TAB & @OSVersion & @LF & "SP:" & @TAB & @OSServicePack, 120, 30, 200, 80)
GUICtrlSetState(-1, $GUI_HIDE)

$cancelbutton = GUICtrlCreateButton("Cancel", 180, 185, 70, 20)

_GUICtrlTreeViewSetBkColor ($treeview, $Turquoise)
_GUICtrlTreeViewSetTextColor ($treeview, $Crimson)
_GUICtrlTreeViewSetLineColor ($treeview, $White)
_GUICtrlTreeViewSetIndent ($treeview, 10)
GUISetState()
_GuiCtrlStatusBarSetText($Status,"Indent: " & _GUICtrlTreeViewGetIndent ($treeview) & " in pixels",255)
While 1
$msg = GUIGetMsg()
Select
Case $msg = $cancelbutton Or $msg = $GUI_EVENT_CLOSE
ExitLoop

Case $msg = $generalitem
ConsoleWrite($generalitem & @LF)
GUIChangeItems($aboutlabel, $compinfo, $startlabel, $startlabel)

Case $msg = $aboutitem
GUICtrlSetState($compinfo, $GUI_HIDE)
GUIChangeItems($startlabel, $startlabel, $aboutlabel, $aboutlabel)

Case $msg = $compitem
GUIChangeItems($startlabel, $aboutlabel, $compinfo, $compinfo)

EndSelect
WEnd

GUIDelete()
Exit

Func GUIChangeItems($hidestart, $hideend, $showstart, $showend)
Local $idx

For $idx = $hidestart To $hideend
GUICtrlSetState($idx, $GUI_HIDE)
Next
For $idx = $showstart To $showend
GUICtrlSetState($idx, $GUI_SHOW)
Next
EndFunc ;==>GUIChangeItems


Function _GUICtrlTreeViewSetLineColor

Function Reference

_GUICtrlTreeViewSetLineColor

Sets the line color of a treeview control

#Include <GuiTreeView.au3>
_GUICtrlTreeViewSetLineColor ( $i_treeview, $v_RGBcolor )

Parameters

$i_treeview | controlID
$v_RGBcolor | New Hex text color

Return Value

Returns the previous Hex RGB line color of the control.

Remarks

None.

Related

_GUICtrlTreeViewGetBkColor, _GUICtrlTreeViewGetLineColor, _GUICtrlTreeViewGetTextColor, _GUICtrlTreeViewSetBkColor, _GUICtrlTreeViewSetTextColor

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <GuiStatusBar.au3>

opt("MustDeclareVars", 1)

Global Const $Turquoise = 0x40e0d0
Global Const $Crimson = 0xDC143C
Global Const $White = 0xFFFFFF

Dim $myGui, $treeview, $generalitem, $displayitem, $aboutitem
Dim $compitem, $useritem, $resitem, $otheritem, $Status, $startlabel, $aboutlabel
Dim $compinfo, $msg, $cancelbutton

$myGui = GUICreate("TreeView Set Line Color", 392, 254)

$treeview = GUICtrlCreateTreeView(6, 6, 100, 150, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$generalitem = GUICtrlCreateTreeViewItem("General", $treeview)
$displayitem = GUICtrlCreateTreeViewItem("Display", $treeview)
$aboutitem = GUICtrlCreateTreeViewItem("About", $generalitem)
$compitem = GUICtrlCreateTreeViewItem("Computer", $generalitem)
$useritem = GUICtrlCreateTreeViewItem("User", $generalitem)
$resitem = GUICtrlCreateTreeViewItem("Resolution", $displayitem)
$otheritem = GUICtrlCreateTreeViewItem("Other", $displayitem)
$Status = _GuiCtrlStatusBarCreate($myGui, -1, "")
_GuiCtrlStatusBarSetSimple($Status)

$startlabel = GUICtrlCreateLabel("TreeView Demo", 190, 90, 100, 20)
$aboutlabel = GUICtrlCreateLabel("This little scripts demonstates the using of a treeview-control.", 190, 70, 100, 60)
GUICtrlSetState(-1, $GUI_HIDE)
$compinfo = GUICtrlCreateLabel("Name:" & @TAB & @ComputerName & @LF & "OS:" & @TAB & @OSVersion & @LF & "SP:" & @TAB & @OSServicePack, 120, 30, 200, 80)
GUICtrlSetState(-1, $GUI_HIDE)

$cancelbutton = GUICtrlCreateButton("Cancel", 180, 185, 70, 20)

_GUICtrlTreeViewSetBkColor ($treeview, $Turquoise)
_GUICtrlTreeViewSetTextColor ($treeview, $Crimson)
_GuiCtrlStatusBarSetText($Status,"Previous Hex RGB Treeview Line Color: " & _GUICtrlTreeViewSetLineColor ($treeview, $White),255)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $cancelbutton Or $msg = $GUI_EVENT_CLOSE
ExitLoop

Case $msg = $generalitem
GUIChangeItems($aboutlabel, $compinfo, $startlabel, $startlabel)

Case $msg = $aboutitem
GUICtrlSetState($compinfo, $GUI_HIDE)
GUIChangeItems($startlabel, $startlabel, $aboutlabel, $aboutlabel)

Case $msg = $compitem
GUIChangeItems($startlabel, $aboutlabel, $compinfo, $compinfo)

EndSelect
WEnd

GUIDelete()
Exit

Func GUIChangeItems($hidestart, $hideend, $showstart, $showend)
Local $idx

For $idx = $hidestart To $hideend
GUICtrlSetState($idx, $GUI_HIDE)
Next
For $idx = $showstart To $showend
GUICtrlSetState($idx, $GUI_SHOW)
Next
EndFunc ;==>GUIChangeItems


Function _GUICtrlTreeViewSetState

Function Reference

_GUICtrlTreeViewSetState

Set the state of the specified treeview item.

#Include <GuiTreeView.au3>
_GUICtrlTreeViewSetState ( $i_treeview, $h_item [, $i_state = 0 [, $i_stateRemove = 0 ] )

Parameters

$i_treeview | controlID
$h_item | item ID/handle to set the state for
$i_state | Optional: the new item state (default 0 - no change) (See Remarks).
$i_stateRemove | Optional: Remove state from item (Default 0 - no state to remove) (See Remarks)

Return Value

Success: Returns TRUE.
Failure: Returns FALSE.

Remarks

State table
State | Value
$TVIS_SELECTED | 2
$TVIS_CUT | 4
$TVIS_DROPHILITED | 8
$TVIS_BOLD | 16
$TVIS_EXPANDED | 32
$TVIS_EXPANDEDONCE | 64
$TVIS_EXPANDPARTIAL | 128

State values can BitOr'ed together as for example BitOr($TVIS_SELECTED, $TVIS_BOLD).

Related

_GUICtrlTreeViewGetState

Example

#include <GUIConstants.au3>
#include <GuiTreeView.au3>

Opt("MustDeclareVars", 1)

Dim $h_GUI, $Msg, $treeview, $h_search, $s_file, $h_item

$h_GUI = GUICreate("TreeView UDF Sample", 220, 220)

$treeview = GUICtrlCreateTreeView(10, 10, 200, 200, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetImage(-1, "shell32.dll", 3, 4)
GUICtrlSetImage(-1, "shell32.dll", 4, 2)

GUISetState()

$h_search = FileFindFirstFile("C:\*.*")
If $h_search <> -1 Then
While 1
$s_file = FileFindNextFile($h_search)
If @error Then ExitLoop
If Not StringInStr(FileGetAttrib("C:\" & $s_file), "D") Then ContinueLoop
$h_item = _GUICtrlTreeViewInsertItem($treeview, $s_file)
_GUICtrlTreeViewSetState($treeview, $h_item, $TVIS_BOLD) ; bold all items
If StringInStr(FileGetAttrib("C:\" & $s_file), "H") Then _
_GUICtrlTreeViewSetState($treeview, $h_item, $TVIS_CUT, $TVIS_BOLD) ; set to appear as hidden, remove bold state
WEnd
EndIf

While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd

Exit


Function _GUICtrlTreeViewSetText

Function Reference

_GUICtrlTreeViewSetText

Set a new text to the specified treeview item.

#Include <GuiTreeView.au3>
_GUICtrlTreeViewSetText ( $i_treeview, $h_item, $s_text )

Parameters

$i_treeview | controlID
$h_item | item ID/handle to set the text of
$s_text | the new item text

Return Value

Success: TRUE.
Failure: FALSE.

Remarks

None.

Related

None.

Example

#include <GUIConstants.au3>
#include <GuiTreeView.au3>

Opt("MustDeclareVars", 1)

Dim $h_GUI, $Msg, $treeview
Dim $h_root1, $h_root2, $h_root3
Dim $n_btn_settext

$h_GUI = GUICreate("TreeView UDF Sample", 220, 250)

$treeview = GUICtrlCreateTreeView(10, 10, 200, 200, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetImage(-1, "shell32.dll", 3, 4)
GUICtrlSetImage(-1, "shell32.dll", 4, 2)

$h_root1 = _GUICtrlTreeViewInsertItem($treeview, "RootItem1")
_GUICtrlTreeViewSetIcon($treeview, $h_root1, "shell32.dll", 7)

_GUICtrlTreeViewInsertItem($treeview, "SubItem1", $h_root1)
_GUICtrlTreeViewInsertItem($treeview, "SubItem2", $h_root1)

$h_root2 = _GUICtrlTreeViewInsertItem($treeview, "RootItem2")
_GUICtrlTreeViewSetIcon($treeview, $h_root2, "shell32.dll", 12)

$h_root3 = _GUICtrlTreeViewInsertItem($treeview, "RootItem3")
_GUICtrlTreeViewInsertItem($treeview, "SubItem3", $h_root3)
_GUICtrlTreeViewInsertItem($treeview, "SubItem4", $h_root3)

$n_btn_settext = GUICtrlCreateButton("Set text", 10, 220, 200, 20)

GUISetState()

While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
ExitLoop

Case $n_btn_settext
_GUICtrlTreeViewSetText($treeview, $h_root1, "New RootItem1 Text")
_GUICtrlTreeViewSetText($treeview, $h_root2, "New RootItem2 Text")

EndSwitch
WEnd

Exit


Function _GUICtrlTreeViewSetTextColor

Function Reference

_GUICtrlTreeViewSetTextColor

Sets the text color of a treeview control.

#Include <GuiTreeView.au3>
_GUICtrlTreeViewSetTextColor ( $i_treeview, $v_RGBcolor )

Parameters

$i_treeview | controlID
$v_RGBcolor | New Hex text color

Return Value

Returns the previous Hex RGB text color of the control.

Remarks

None.

Related

_GUICtrlTreeViewGetBkColor, _GUICtrlTreeViewGetLineColor, _GUICtrlTreeViewGetTextColor, _GUICtrlTreeViewSetBkColor, _GUICtrlTreeViewSetLineColor

Example

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <GuiStatusBar.au3>

opt("MustDeclareVars", 1)

Global Const $Turquoise = 0x40e0d0
Global Const $Crimson = 0xDC143C
Global Const $White = 0xFFFFFF

Dim $myGui, $treeview, $generalitem, $displayitem, $aboutitem
Dim $compitem, $useritem, $resitem, $otheritem, $Status, $startlabel, $aboutlabel
Dim $compinfo, $msg, $cancelbutton

$myGui = GUICreate("TreeView Set Text Color", 392, 254)

$treeview = GUICtrlCreateTreeView(6, 6, 100, 150, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$generalitem = GUICtrlCreateTreeViewItem("General", $treeview)
$displayitem = GUICtrlCreateTreeViewItem("Display", $treeview)
$aboutitem = GUICtrlCreateTreeViewItem("About", $generalitem)
$compitem = GUICtrlCreateTreeViewItem("Computer", $generalitem)
$useritem = GUICtrlCreateTreeViewItem("User", $generalitem)
$resitem = GUICtrlCreateTreeViewItem("Resolution", $displayitem)
$otheritem = GUICtrlCreateTreeViewItem("Other", $displayitem)
$Status = _GuiCtrlStatusBarCreate($myGui, -1, "")
_GuiCtrlStatusBarSetSimple($Status)

$startlabel = GUICtrlCreateLabel("TreeView Demo", 190, 90, 100, 20)
$aboutlabel = GUICtrlCreateLabel("This little scripts demonstates the using of a treeview-control.", 190, 70, 100, 60)
GUICtrlSetState(-1, $GUI_HIDE)
$compinfo = GUICtrlCreateLabel("Name:" & @TAB & @ComputerName & @LF & "OS:" & @TAB & @OSVersion & @LF & "SP:" & @TAB & @OSServicePack, 120, 30, 200, 80)
GUICtrlSetState(-1, $GUI_HIDE)

$cancelbutton = GUICtrlCreateButton("Cancel", 180, 185, 70, 20)

_GUICtrlTreeViewSetBkColor ($treeview, $Turquoise)
_GuiCtrlStatusBarSetText($Status,"Previous Hex RGB Treeview Text Color: " & _GUICtrlTreeViewSetTextColor ($treeview, $Crimson),255)
_GUICtrlTreeViewSetLineColor ($treeview, $White)

GUISetState()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $cancelbutton Or $msg = $GUI_EVENT_CLOSE
ExitLoop

Case $msg = $generalitem
GUIChangeItems($aboutlabel, $compinfo, $startlabel, $startlabel)

Case $msg = $aboutitem
GUICtrlSetState($compinfo, $GUI_HIDE)
GUIChangeItems($startlabel, $startlabel, $aboutlabel, $aboutlabel)

Case $msg = $compitem
GUIChangeItems($startlabel, $aboutlabel, $compinfo, $compinfo)

EndSelect
WEnd

GUIDelete()
Exit

Func GUIChangeItems($hidestart, $hideend, $showstart, $showend)
Local $idx

For $idx = $hidestart To $hideend
GUICtrlSetState($idx, $GUI_HIDE)
Next
For $idx = $showstart To $showend
GUICtrlSetState($idx, $GUI_SHOW)
Next
EndFunc ;==>GUIChangeItems


Function _GUICtrlTreeViewSort

Function Reference

_GUICtrlTreeViewSort

Sorts the items of a treeview control.

#Include <GuiTreeView.au3>
_GUICtrlTreeViewSort ( $i_treeview )

Parameters

$i_treeview controlID

Return Value

None.

Remarks

None.

Related

None.

Example

#include <GuiTreeView.au3>

opt("MustDeclareVars", 1)
Dim $h_GUI, $treeview, $nItem1, $nItem2, $nItem3
Dim $nSubItem1, $nSubItem2, $nSubItem3, $nSubItem4, $nSubItem5, $nSubItem6, $nSubItem7
Dim $Btn_Sort, $Msg

$h_GUI = GUICreate("TreeView Sort", 392, 254)

$treeview = GUICtrlCreateTreeView(10, 10, 200, 150)
$nItem2 = GUICtrlCreateTreeViewItem("Item2", $treeview)
$nItem1 = GUICtrlCreateTreeViewItem("Item1", $treeview)
$nItem3 = GUICtrlCreateTreeViewItem("Item3", $treeview)
$nSubItem2 = GUICtrlCreateTreeViewItem("SubItem2", $nItem1)
$nSubItem1 = GUICtrlCreateTreeViewItem("SubItem1", $nItem1)
$nSubItem4 = GUICtrlCreateTreeViewItem("SubItem4", $nSubItem1)
$nSubItem5 = GUICtrlCreateTreeViewItem("SubItem5", $nSubItem4)
$nSubItem6 = GUICtrlCreateTreeViewItem("SubItem6", $nSubItem5)
$nSubItem3 = GUICtrlCreateTreeViewItem("SubItem3", $nSubItem1)
$nSubItem7 = GUICtrlCreateTreeViewItem("SubItem7", $nItem3)

$Btn_Sort = GUICtrlCreateButton("Sort", 70, 170, 90, 20)

GUISetState()

While 1
$Msg = GUIGetMsg()
Select
Case $Msg = $GUI_EVENT_CLOSE
ExitLoop
Case $Msg = $Btn_Sort
_GUICtrlTreeViewSort ($treeview)
EndSelect
WEnd

Exit


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: IE Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_IE_Example | Display a new browser window pre-loaded with documents to be used in IE.au3 examples or your own testing
_IE_Introduction | Display introductory information about IE.au3 in a new browser window
_IE_VersionInfo | Returns an array of information about the IE.au3 version
_IEAction | Perform any of a set of simple actions on the Browser.
_IEAttach | Attach to the first existing instance of Internet Explorer where the search string sub-string matches based on the selected mode.
_IEBodyReadHTML | Returns the HTML inside the <body> tag of the document.
_IEBodyReadText | Returns the Text inside the <body> tag of the document.
_IEBodyWriteHTML | Replaces the HTML inside the <body> tag of the document.
_IECreate | Create an Internet Explorer Browser Window.
_IECreateEmbedded | Create a Webbrowser object suitable for embedding in an AutoIt GUI with GuiCtrlCreateObj().
_IEDocGetObj | Given any DOM object, returns a reference to the associated document object.
_IEDocInsertHTML | Inserts HTML Text in or around an element.
_IEDocInsertText | Inserts Text in or around an element.
_IEDocReadHTML | Returns the full HTML source of a document.
_IEDocWriteHTML | Replaces the HTML for the entire document.
_IEErrorHandlerDeRegister | Disable a registered user COM error handler
_IEErrorHandlerRegister | Register and enable a user COM error handler
_IEErrorNotify | Specifies whether IE.au3 automatically notifies of Warnings and Errors (to the console)
_IEFormElementCheckboxSelect | Set the value of a specified form element.
_IEFormElementGetCollection | Returns a collection object variable representing all Form Elements within a given Form.
_IEFormElementGetObjByName | Returns an object reference to a Form Element by name.
_IEFormElementGetValue | Returns the value of a given Form Element.
_IEFormElementOptionSelect | Set the value of a specified form element.
_IEFormElementRadioSelect | Set the value of a specified form element.
_IEFormElementSetValue | Set the value of a specified Form Element.
_IEFormGetCollection | Returns a collection object variable representing the Forms in the document or a single form by index.
_IEFormGetObjByName | Returns an object reference to a Form by name.
_IEFormImageClick | Simulate a mouse click on an <input type=image>. Match by sub-string match of alt text, name or src.
_IEFormReset | Reset a specified Form setting the values back to their loaded defaults.
_IEFormSubmit | Submit a specified Form.
_IEFrameGetCollection | Returns a collection object containing the frames in a FrameSet or the iFrames on a normal page or a single Frame or iFrame by index.
_IEFrameGetObjByName | Returns an object reference to a Frame or iFrame by name.
_IEGetObjById | Returns an object variable by id or name.
_IEGetObjByName | Returns an object variable by name or id.
_IEHeadInsertEventScript | Inserts a Javascript into the Head of the document.
_IEImgClick | Simulate a mouse click on an image. Match by sub-string match of alt text, name, or src.
_IEImgGetCollection | Returns a collection object variable representing the IMG tags in the document or a single image by index.
_IEIsFrameSet | Checks to see if the specified Window contains a FrameSet.
_IELinkClickByIndex | Simulate a mouse click on a link by 0-based index (in source order).
_IELinkClickByText | Simulate a mouse click on a link with text sub-string matching the string provided.
_IELinkGetCollection | Returns a collection object containing all links in the document or a single link by index.
_IELoadWait | Wait for a browser page load to complete before returning.
_IELoadWaitTimeout | Retrieve or set the current value in milliseconds _IELoadWait will try before timing out.
_IENavigate | Directs an existing browser window to navigate to the specified URL.
_IEPropertyGet | Returns a select property of the Browser or DOM element.
_IEPropertySet | Set a select property of the Browser or DOM element.
_IEQuit | Close the browser and remove the object reference to it.
_IETableGetCollection | Returns a collection object variable representing all the tables in a document or a single table by index.
_IETableWriteToArray | Reads the contents of a Table into an array.
_IETagNameAllGetCollection | Returns a collection object all elements in the document or document hierarchy in source order or a single element by index.
_IETagNameGetCollection | Returns a collection object of all elements in the object with the specified TagName or a single element by index.


Function _IE_Example

Function Reference

_IE_Example

Display a new browser window pre-loaded with documents to be used in IE.au3 examples or your own testing

#include <IE.au3>
_IE_Example ( [$s_module = "basic"] )

Parameters

$s_module Optional: specifies which module to run
basic = (Default) simple HTML page with text, links and images
form = simple HTML page with multiple form elements
frameset = simple HTML page with frames
iframe = simple HTML page with iframes
table = simple HTML page with tables

Return Value

Success: | Returns an object variable pointing to an InternetExplorer.Application object
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 5 ($_IEStatus_InvalidValue) = Invalid Value
@Extended: | Contains invalid parameter number

Remarks

This function displays browser windows pre-populated with HTML and HTML elements that are used throughout the helpfile and IE.au3 examples. You are also encouraged to use them to experiment with the IE.au3 function set.

Related

_IE_Introduction

Example

; *******************************************************
; Example 1 - Create browser windows with each of the example pages displayed.
; The object variable returned can be used just as the object
; variables returned by _IECreate or _IEAttach
; *******************************************************
;
#include <IE.au3>
$oIE_basic = _IE_Example ("basic")
$oIE_form = _IE_Example ("form")
$oIE_table = _IE_Example ("table")
$oIE_frameset = _IE_Example ("frameset")
$oIE_iframe = _IE_Example ("iframe")


Function _IE_Introduction

Function Reference

_IE_Introduction

Display introductory information about IE.au3 in a new browser window

#include <IE.au3>
_IE_Introduction ( [$s_module = "basic"] )

Parameters

$s_module Optional: specifies which module to run
basic = (Default) basic introduction

Return Value

Success: | Returns an object variable pointing to an InternetExplorer.Application object
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 5 ($_IEStatus_InvalidValue) = Invalid Value
@Extended: | Contains invalid parameter number

Remarks

The AutoIt Helpfile does not currently allow UDFs to have general documentation that covers a series of functions, but rather UDF documentation is focused on individual functions. This function is intended to provide that general documentation. It will grow over time.

Related

_IE_Example

Example

; *******************************************************
; Example 1 - Open a browser with the basic IE.au3 introductory text displayed
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Introduction ("basic")


Function _IE_VersionInfo

Function Reference

_IE_VersionInfo

Returns an array of information about the IE.au3 version

#include <IE.au3>
_IE_VersionInfo ( )

Parameters

None.

Return Value

Success: | Returns an array ($IEAU3VersionInfo)
 | $IEAU3VersionInfo[0] = Release Type (T=Test or V=Production)
 | $IEAU3VersionInfo[1] = Major Version
 | $IEAU3VersionInfo[2] = Minor Version
 | $IEAU3VersionInfo[3] = Sub Version
 | $IEAU3VersionInfo[4] = Release Date (YYYYMMDD)
 | $IEAU3VersionInfo[5] = Display Version (e.g. V2.1-0)
Failure: | None

Remarks

The array contents make it easy to determine of the UDF version is higher or lower than a required version.

Related

None.

Example

; *******************************************************
; Example 1 - Retrieve and display IE.au3 version information
; *******************************************************
;
#include <IE.au3>
$aVersion = _IE_VersionInfo ()
MsgBox(0, "IE.au3 Version", $aVersion[5] & " released " & $aVersion[4])


Function _IEAction

Function Reference

_IEAction

Perform any of a set of simple actions on the Browser.

#include <IE.au3>
_IEAction ( ByRef $o_object, $s_action )

Parameters

$o_object | Object variable of an InternetExplorer.Application
$s_action | Action selection (see remarks)

Return Value

Success: | Returns 1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
 | 5 ($_IEStatus_InvalidValue) = Invalid Value
@Extended: | Contains invalid parameter number

Remarks

Action | Description
"back" | Navigates backward one item in the history list.
"blur" | Causes the element to lose focus, but does not set focus on the next element in the tab order.
"click" | Simulates a click on the specified element.
"copy" | Copies the current selection to the clipboard.
"cut" | Copies the current selection to the clipboard and then deletes it.
"delete" | Deletes the current selection.
"disable" | Disables the specified element.
"enable" | Enables the specified element.
"focus" | Causes the element to receive focus.
"forward" | Navigates forward one item in the history list.
"home" | Navigates to the current home or start page.
"invisible" | Sets an object state to hidden.
"paste" | Overwrites the contents of the clipboard on the current selection.
"print" | Opens the print dialog box so the user can print the current page.
"printdefault" | Print directly to default printer (no dialog)
"quit" | Closes the object.
"refresh" | Refreshes the current document.
"saveas" | Opens a dialog box to save the current Web page to a file.
"search" | Navigates to the current search page.
"selectall" | Selects the entire document.
"stop" | Cancels any pending navigation or download operation and stops any dynamic page elements, such as background sounds and animations.
"unselect" | Clears the current selection.
"visible" | Sets an object state to visible.

Related

_IEPropertySet

Example

; *******************************************************
; Example 1 - Open a browser with the "form" example, get a reference
; to the submit button by name and "click" it. This technique
; of submitting forms is useful because many forms rely on JavaScript
; code and "onClick" events on their submit button making _IEFormSubmit()
; not perform as expected
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("form")
$oSubmit = _IEGetObjByName ($oIE, "submitExample")
_IEAction ($oSubmit, "click")
_IELoadWait ($oIE)

; *******************************************************
; Example 2 - Same as Example 1, except instead of using click, give the element focus
; and then use ControlSend to send Enter. Use this technique when the
; browser-side scripting associated with a click action prevents control
; from being automatically returned to your code.
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("form")
$oSubmit = _IEGetObjByName ($oIE, "submitExample")
$hwnd = _IEPropertyGet($oIE, "hwnd")
_IEAction ($oSubmit, "focus")
ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}")

; Wait for Alert window, then click on OK
WinWait("Windows Internet Explorer", "ExampleFormSubmitted")
ControlClick("Windows Internet Explorer", "ExampleFormSubmitted", "[CLASS:Button; TEXT:OK; Instance:1;]")
_IELoadWait ($oIE)


Function _IEAttach

Function Reference

_IEAttach

Attach to the first existing instance of Internet Explorer where the search string sub-string matches based on the selected mode.

#include <IE.au3>
_IEAttach ( $s_string [, $s_mode = "Title"] )

Parameters

$s_string | String to search for (for "embedded" or "dialogbox", use Title sub-string or HWND of window)
$s_mode | Optional: specifies search mode Title = (Default) sub-string of main document title WindowTitle = sub-string of full window title (instead of document title) URL = sub-string or url of the current page Text = sub-string in text from the body of the current page HTML = sub-string in html from the body of the current page HWND = hwnd of the browser window Embedded = title sub-string or hwnd of of the window embedding the control DialogBox = title sub-string or hwnd of modal/modeless dialogbox

Return Value

Success: | Returns an object variable pointing to the IE Window Object
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 5 ($_IEStatus_InvalidValue) = Invalid Value
 | 7 ($_IEStatus_NoMatch) = No Match
@Extended: | Contains invalid parameter number

Remarks

_IEAttach provides the "DialogBox" parameter to attach to modal and modeless dialogs created by the browser. It is important to note that not all dialogs created through browser interaction can be attached to and controlled in this way. Many of these dialogs are actually standard windows and can be controlled through the traditional AutoIt window functions. A reliable way to tell the difference between these types of windows is to use the "AutoIt Window Info" tool to examine it -- if the window contains a control called "Internet Explorer_Server1" then you can attach to it with this function, if it does not it is a standard window and traditional AutoIt windows functions must be used to control it.

The "embedded" option must be used to attach to HyperTextApplication (.hta) windows.

Related

_IECreate, _IECreateEmbedded, _IEQuit

Example

; *******************************************************
; Example 1 - Attach to a browser with "AutoIt" in its title, display the URL
; *******************************************************
;
#include <IE.au3>
$oIE = _IEAttach ("AutoIt")
MsgBox(0, "The URL", _IEPropertyGet ($oIE, "locationurl"))

; *******************************************************
; Example 2 - Attach to a browser with "The quick brown fox"
; in the text of it's top-level document
; *******************************************************
;
#include <IE.au3>
$oIE = _IEAttach ("The quick brown fox", "text")

; *******************************************************
; Example 3 - ; Attach to a browser control embedded in another window
; *******************************************************
;
#include <IE.au3>
$oIE = _IEAttach ("A Window Title", "embedded")


Function _IEBodyReadHTML

Function Reference

_IEBodyReadHTML

Returns the HTML inside the <body> tag of the document.

#include <IE.au3>
_IEBodyReadHTML ( ByRef $o_object )

Parameters

$o_object Object variable of an InternetExplorer.Application, Window or Frame object

Return Value

Success: | Returns HTML included in the <body> of the document
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
@Extended: | Contains invalid parameter number

Remarks

This function uses the .innerHTML property of the document Body. .innerHTML is available for nearly all DOM elements using _IEPropertyGet.

Related

_IEBodyReadText, _IEBodyWriteHTML, _IEPropertyGet

Example

; *******************************************************
; Example 1 - Open a browser with the basic example, ready the body HTML,
; append new HTML to the original and write it back to the browser
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("basic")
$sHTML = _IEBodyReadHTML ($oIE)
$sHTML = $sHTML & "<p><font color=red size=+5>Big RED text!</font>"
_IEBodyWriteHTML ($oIE, $sHTML)


Function _IEBodyReadText

Function Reference

_IEBodyReadText

Returns the Text inside the <body> tag of the document.

#include <IE.au3>
_IEBodyReadText ( ByRef $o_object )

Parameters

$o_object Object variable of an InternetExplorer.Application, Window or Frame object

Return Value

Success: | Returns the Text included in the <body> of the document
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
@Extended: | Contains invalid parameter number

Remarks

This function uses the .innerText property of the document Body. .innerText is available for nearly all DOM elements and is a fast convenient method of parsing out just the text in a document using _IEPropertyGet.

Related

_IEBodyReadHTML, _IEBodyWriteHTML, _IEPropertyGet

Example

; *******************************************************
; Example 1 - Open a browser with the basic example, read the body Text
; (the content with all HTML tags removed) and display it in a MsgBox
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("basic")
$sText = _IEBodyReadText ($oIE)
MsgBox(0, "Body Text", $sText)


Function _IEBodyWriteHTML

Function Reference

_IEBodyWriteHTML

Replaces the HTML inside the <body> tag of the document.

#include <IE.au3>
_IEBodyWriteHTML ( ByRef $o_object, $s_html )

Parameters

$o_object | Object variable of an InternetExplorer.Application, Window or Frame object
$s_html | The HTML string to write to the document

Return Value

Success: | Returns -1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 1 ($_IEStatus_GeneralError) = General Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
 | 6 ($_IEStatus_LoadWaitTimeout) = Load Wait Timeout
 | 8 ($_IEStatus_AccessIsDenied) = Access Is Denied
 | 9 ($_IEStatus_ClientDisconnected) = Client Disconnected
@Extended: | Contains invalid parameter number

Remarks

You may use _IEBodyReadHTML to read the current HTML contents of the document body, manipulat that string and then write it back with _IEBodyWriteHTML. You may also use _IEDocInsertHTML, _IEDocInsertText and the innerHTML, innerText, outerHTML and outerText features of _IEPropertyGet and _IEPropertySet to control specific elements without rewriting large blocks of text.

Related

_IEBodyReadHTML, _IEBodyReadText, _IEDocInsertHTML, _IEDocInsertText, _IEPropertyGet, _IEPropertySet

Example

; *******************************************************
; Example 1 - Open a browser with the iFrame example, get a reference
; to the iFrame with a name of "iFrameTwo" and replace its body HTML
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("iframe")
$oFrame = _IEFrameGetObjByName ($oIE, "iFrameTwo")
_IEBodyWriteHTML ($oFrame, "Hello <b>iFrame!</b>")


Function _IECreate

Function Reference

_IECreate

Create an Internet Explorer Browser Window.

#include <IE.au3>
_IECreate ( [$s_Url = "about:blank" [, $f_tryAttach = 0 [, $f_visible = 1 [, $f_wait = 1 [, $f_takeFocus = -1]]]]] )

Parameters

$s_Url | Optional: specifies the Url to navigate to upon creation
$f_tryAttach | Optional: specifies whether to try to attach to an existing window 0 = (Default) do not try to attach 1 = Try to attach to an existing window
$f_visible | Optional: specifies whether the browser window will be visible 0 = Browser Window is hidden 1 = (Default) Browser Window is visible
$f_wait | Optional: specifies whether to wait for page to load before returning 0 = Return immediately, not waiting for page to load 1 = (Default) Wait for page load to complete before returning
$f_takeFocus | Optional: specifies whether to bring the attached window to focus 0 = Bring window into focus -1 = (Default) do not bring window into focus

Return Value

Success: | Returns an object variable pointing to an InternetExplorer.Application object
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 1 ($_IEStatus_GeneralError) = General Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
 | 6 ($_IEStatus_LoadWaitTimeout) = Load Wait Timeout
 | 8 ($_IEStatus_AccessIsDenied) = Access Is Denied
 | 9 ($_IEStatus_ClientDisconnected) = Client Disconnected
@Extended: | Set to true (1) or false (0) depending on the success of $f_tryAttach

Remarks

When using tryAttach, a No Match error will be displayed to the console from _IEAttach. This can be controlled with _IEErrorNotify.

When opening a local HyperTextApplication (.hta) file, Internet Explorer will open a new browser process for it that will not be accessible through the object variable returned by _IECreate. To control this new browser you must use _IEAttach with the "embedded" option.

Related

_IEAttach, _IECreateEmbedded, _IEQuit, _IENavigate

Example

; *******************************************************
; Example 1 - Create a browser window and navigate to a website
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("www.autoitscript.com")

; *******************************************************
; Example 2 - Create new browser windows pointing to each of 3 different URLs
; if one does not already exist ($f_tryAttach = 1)
; do not wait for the page loads to complete ($f_wait = 0)
; *******************************************************
;
#include <IE.au3>
_IECreate ("www.autoitscript.com", 1, 1, 0)
_IECreate ("my.yahoo.com", 1, 1, 0)
_IECreate ("www.google.com", 1, 1, 0)

; *******************************************************
; Example 3 - Attempt to attach to an existing browser displaying a particular website URL
; Create a new browser and navigate to that site if one does not already exist
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("www.autoitscript.com", 1)
; Check @extended return value to see if attach was successful
If @extended Then
MsgBox(0, "", "Attached to Existing Browser")
Else
MsgBox(0, "", "Created New Browser")
EndIf

; *******************************************************
; Example 4 - Create an empty browser window and populate it with custom HTML
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ()
$sHTML = "<h1>Hello World!</h1>"
_IEBodyWriteHTML ($oIE, $sHTML)

; *******************************************************
; Example 5 - Create an invisible browser window, navigate to a website,
; retrieve some information and Quit
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("http://sourceforge.net", 0, 0)
; Display the innerText on an element on the page with a name of "sfmarquee"
$oMarquee = _IEGetObjByName ($oIE, "sfmarquee")
MsgBox(0, "SourceForge Information", $oMarquee.innerText)
_IEQuit ($oIE)


Function _IECreateEmbedded

Function Reference

_IECreateEmbedded

Create a Webbrowser object suitable for embedding in an AutoIt GUI with GuiCtrlCreateObj().

#include <IE.au3>
_IECreateEmbedded ( )

Parameters

None.

Return Value

Success: | Returns a Webbrowser object reference
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 1 ($_IEStatus_GeneralError) = General Error

Remarks

No actions can be performed on this object until it has been embedded into a parent application (e.g. you cannot perform an _IENavigate).

There are several properties related to an InternetExplorer object (e.g. returned by _IECreate) that do not apply to this object. These include status text, addressbar and others that may exist for a browser, but do not exist for an embedded control.

_IEQuit cannot be used with this object. The object will be destroyed when its parent GUI is destroyed.

Related

GUICtrlCreateObj, _IEAttach, _IECreate

Example

; *******************************************************
; Example 1 - Trap COM errors so that 'Back' and 'Forward'
; outside of history bounds does not abort script
; (expect COM errors to be sent to the console)
; *******************************************************
;
#include <GUIConstants.au3>
#include <IE.au3>

_IEErrorHandlerRegister ()

$oIE = _IECreateEmbedded ()
GUICreate("Embedded Web control Test", 640, 580, _
(@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _
$WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 600, 360)
$GUI_Button_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30)
$GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30)
$GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30)
$GUI_Button_Stop = GUICtrlCreateButton("Stop", 340, 420, 100, 30)

GUISetState() ;Show GUI

_IENavigate ($oIE, "http://www.autoitscript.com")

; Waiting for user to close the window
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $GUI_Button_Home
_IENavigate ($oIE, "http://www.autoitscript.com")
Case $msg = $GUI_Button_Back
_IEAction ($oIE, "back")
Case $msg = $GUI_Button_Forward
_IEAction ($oIE, "forward")
Case $msg = $GUI_Button_Stop
_IEAction ($oIE, "stop")
EndSelect
WEnd

GUIDelete()

Exit


Function _IEDocGetObj

Function Reference

_IEDocGetObj

Given any DOM object, returns a reference to the associated document object.

#include <IE.au3>
_IEDocGetObj ( ByRef $o_object )

Parameters

$o_object Object variable of an InternetExplorer.Application, Window, Frame or any DOM object

Return Value

Success: | Returns an object variable pointing to the Document object
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
@Extended: | Contains invalid parameter number

Remarks

Given any DOM object (e.g. Browser, Window, Frame, iFrame, Document or Document Element) this will return a reference to the associated document object. It is particularly useful when writing generalized functions when you cannot control the type of object that will be passed in.

Related

None.

Example

; *******************************************************
; Example 1 - Open a browser to the AutoIt Homepage, get a reference
; to the document object and display a document attribute
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("http://www.autoitscript.com")
$oDoc = _IEDocGetObj ($oIE)
MsgBox(0, "Document Created Date", $oDoc.fileCreatedDate)


Function _IEDocInsertHTML

Function Reference

_IEDocInsertHTML

Inserts HTML Text in or around an element.

#include <IE.au3>
_IEDocInsertHTML ( ByRef $o_object, $s_string [, $s_where = "beforeend"] )

Parameters

$o_object | Object variable pointing to a document element.
$s_string | The string containing the HTML text to insert.
$s_where | Optional: specifies the string insertion point beforebegin = Inserts string immediately before the object. afterbegin = Inserts string after the start of the object but before all other content in the object. beforeend = (Default) Inserts string immediately before the end of the object but after all other content in the object. afterend = Inserts string immediately after the end of the object.

Return Value

Success: | Returns 1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
 | 5 ($_IEStatus_InvalidValue) = Invalid Value
@Extended: | Contains invalid parameter number

Remarks

The innerHTML, outerHTML, innerText and outerText features of _IEPropertySet can be used to dynamically manipulate inserted content.

Related

_IEDocInsertText, _IEPropertyGet, _IEPropertySet, _IEBodyReadHTML, _IEBodyWriteHTML, _IEDocReadHTML, _IEHeadInsertEventScript

Example

; *******************************************************
; Example 1 - Insert HTML at the top and bottom of a document
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate("http://www.autoitscript.com")
$oBody = _IETagNameGetCollection($oIE, "body", 0)
_IEDocInsertHTML($oBody, "<h2>This HTML is inserted After Begin</h2>", "afterbegin")
_IEDocInsertHTML($oBody, "<h2>This HTML is inserted Before End</h2>", "beforeend")

; *******************************************************
; Example 2 - Open a browser with the basic example page, insert HTML
; in and around the DIV tag named "IEAu3Data" and display Body HTML
; *******************************************************
;
$oIE = _IE_Example ("basic")
$oDiv = _IEGetObjByName($oIE, "IEAu3Data")

_IEDocInsertHTML($oDiv, "<b>(HTML beforebegin)</b>", "beforebegin")
_IEDocInsertHTML($oDiv, "<i>(HTML afterbegin)</i>", "afterbegin")
_IEDocInsertHTML($oDiv, "<b>(HTML beforeend)</b>", "beforeend")
_IEDocInsertHTML($oDiv, "<i>(HTML afterend)</i>", "afterend")

ConsoleWrite(_IEBodyReadHTML($oIE) & @CR)

; *******************************************************
; Example 3 - Advanced example
; Insert a clock and a referrer string at the top of every page, even when you
; browse to a new location. Uses _IEDocInsertText, _IEDocInsertHTML and
; _IEPropertySet features "innerhtml" and "referrer"
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate("http://www.autoitscript.com")

AdlibEnable("UpdateClock", 1000) ; Update clock once per second

; idle as long as the browser window exists
While WinExists(_IEPropertyGet($oIE, "hwnd"))
Sleep(10000)
WEnd

Exit

Func UpdateClock()
Local $curTime = "<b>Current Time is: </b>" & @HOUR & ":" & @MIN & ":" & @SEC
; _IEGetObjByName is expected to return a NoMatch error after navigation
; (before DIV is inserted), so temporarily turn off notification
_IEErrorNotify(False)
Local $oAutoItClock = _IEGetObjByName($oIE, "AutoItClock")
If Not IsObj($oAutoItClock) Then ; Insert DIV element if it wasn't found
;
; Get reference to BODY, insert DIV, get reference to DIV, update time
$oBody = _IETagNameGetCollection($oIE, "body", 0)
_IEDocInsertHTML($oBody, "<div id='AutoItClock'></div>", "afterbegin")
$oAutoItClock = _IEGetObjByName($oIE, "AutoItClock")
_IEPropertySet($oAutoItClock, "innerhtml", $curTime)
;
; Check referrer string, if not blank insert after clock
_IELoadWait($oIE)
$sReferrer = _IEPropertyGet($oIE, "referrer")
If $sReferrer Then _IEDocInsertText($oAutoItClock, _
" Referred by: " & $sReferrer, "afterend")
Else
_IEPropertySet($oAutoItClock, "innerhtml", $curTime) ; update time
EndIf
_IEErrorNotify(True)
EndFunc


Function _IEDocInsertText

Function Reference

_IEDocInsertText

Inserts Text in or around an element.

#include <IE.au3>
_IEDocInsertText ( ByRef $o_object, $s_string [, $s_where = "beforeend"] )

Parameters

$o_object | Object variable pointing to a document element.
$s_string | The string containing the text to insert.
$s_where | Optional: specifies the string insertion point beforebegin = Inserts string immediately before the object. afterbegin = Inserts string after the start of the object but before all other content in the object. beforeend = (Default) Inserts string immediately before the end of the object but after all other content in the object. afterend = Inserts string immediately after the end of the object.

Return Value

Success: | Returns 1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
 | 5 ($_IEStatus_InvalidValue) = Invalid Value
@Extended: | Contains invalid parameter number

Remarks

In the text to be inserted includes HTML tags, they are first converted so that they display as text. The innerHTML, outerHTML, innerText and outerText features of _IEPropertySet can be used to dynamically manipulate inserted content.

Related

_IEDocInsertHTML, _IEPropertyGet, _IEPropertySet, _IEBodyReadHTML, _IEBodyWriteHTML, _IEDocReadHTML, _IEHeadInsertEventScript

Example

; *******************************************************
; Example 1 - Open a browser with the basic example page, insert text
; in and around the first Paragraph tag and display Body HTML
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("basic")
$oP = _IETagNameGetCollection($oIE, "p", 0)

_IEDocInsertText($oP, "(Text beforebegin)", "beforebegin")
_IEDocInsertText($oP, "(Text afterbegin)", "afterbegin")
_IEDocInsertText($oP, "(Text beforeend)", "beforeend")
_IEDocInsertText($oP, "(Text afterend)", "afterend")

ConsoleWrite(_IEBodyReadHTML($oIE) & @CR)

; *******************************************************
; Example 2 - Insert HTML at the top and bottom of a document
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("basic")
$oBody = _IETagNameGetCollection($oIE, "body", 0)
_IEDocInsertText($oBody, "This Text is inserted After Begin", "afterbegin")
_IEDocInsertText($oBody, "Notice that <b>Tags</b> are <encoded> before display", "beforeend")

; *******************************************************
; Example 3 - Advanced example
; Insert a clock and a referrer string at the top of every page, even when you
; browse to a new location. Uses _IEDocInsertText, _IEDocInsertHTML and
; _IEPropertySet features "innerhtml" and "referrer"
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate("http://www.autoitscript.com")

AdlibEnable("UpdateClock", 1000) ; Update clock once per second

; idle as long as the browser window exists
While WinExists(_IEPropertyGet($oIE, "hwnd"))
Sleep(10000)
WEnd

Exit

Func UpdateClock()
Local $curTime = "<b>Current Time is: </b>" & @HOUR & ":" & @MIN & ":" & @SEC
; _IEGetObjByName is expected to return a NoMatch error after navigation
; (before DIV is inserted), so temporarily turn off notification
_IEErrorNotify(False)
Local $oAutoItClock = _IEGetObjByName($oIE, "AutoItClock")
If Not IsObj($oAutoItClock) Then ; Insert DIV element if it wasn't found
;
; Get reference to BODY, insert DIV, get reference to DIV, update time
$oBody = _IETagNameGetCollection($oIE, "body", 0)
_IEDocInsertHTML($oBody, "<div id='AutoItClock'></div>", "afterbegin")
$oAutoItClock = _IEGetObjByName($oIE, "AutoItClock")
_IEPropertySet($oAutoItClock, "innerhtml", $curTime)
;
; Check referrer string, if not blank insert after clock
_IELoadWait($oIE)
$sReferrer = _IEPropertyGet($oIE, "referrer")
If $sReferrer Then _IEDocInsertText($oAutoItClock, _
" Referred by: " & $sReferrer, "afterend")
Else
_IEPropertySet($oAutoItClock, "innerhtml", $curTime) ; update time
EndIf
_IEErrorNotify(True)
EndFunc


Function _IEDocReadHTML

Function Reference

_IEDocReadHTML

Returns the full HTML source of a document.

#include <IE.au3>
_IEDocReadHTML ( ByRef $o_object )

Parameters

$o_object Object variable of an InternetExplorer.Application, Window or Frame object

Return Value

Success: | Returns the HTML included in the <HTML> of the document, including the <HTML> and </HTML> tags
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
@Extended: | Contains invalid parameter number

Remarks

This function returns the document source after any client-side modifications (e.g. by AutoIt or by client-side JavaScript). It may therefore be different than what is shown by the browser View Source or by _INetGetSource.

Related

_IEDocWriteHTML, _IEBodyReadHTML, _INetGetSource

Example

; *******************************************************
; Example 1 - Open a browser with the basic example, read the document HTML
; (all HTML including the <HEAD> and script) and display it in a MsgBox
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("basic")
$sHTML = _IEDocReadHTML ($oIE)
MsgBox(0, "Document Source", $sHTML)


Function _IEDocWriteHTML

Function Reference

_IEDocWriteHTML

Replaces the HTML for the entire document.

#include <IE.au3>
_IEDocWriteHTML ( ByRef $o_object, $s_html )

Parameters

$o_object | Object variable of an InternetExplorer.Application, Window or Frame object
$s_html | The HTML string to write to the document

Return Value

Success: | Returns -1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 1 ($_IEStatus_GeneralError) = General Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
 | 6 ($_IEStatus_LoadWaitTimeout) = Load Wait Timeout
 | 8 ($_IEStatus_AccessIsDenied) = Access Is Denied
 | 9 ($_IEStatus_ClientDisconnected) = Client Disconnected
@Extended: | Contains invalid parameter number

Remarks

This function completely replaces the content of the document in a browser or a frame. It can be used to create a new page with custom HTML and JavaScript.

It is sometimes necessary to refresh the page after writing with _IEAction($oIE, "refresh") (e,g, after creating a FRAMESET).

Related

_IEDocReadHTML

Example

; *******************************************************
; Example 1 - Create an empty browser, write customer HTML to it - in this case a
; FRAMESET - and then update the contents of each of the frames
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ()
$sHTML = ""
$sHTML &= "<HTML>" & @CR
$sHTML &= "<HEAD>" & @CR
$sHTML &= "<TITLE>_IE_Example('frameset')</TITLE>" & @CR
$sHTML &= "</HEAD>" & @CR
$sHTML &= "<FRAMESET rows='25,200'>" & @CR
$sHTML &= " <FRAME NAME=Top SRC=about:blank>" & @CR
$sHTML &= " <FRAMESET cols='100,500'>" & @CR
$sHTML &= " <FRAME NAME=Menu SRC=about:blank>" & @CR
$sHTML &= " <FRAME NAME=Main SRC=about:blank>" & @CR
$sHTML &= " </FRAMESET>" & @CR
$sHTML &= "</FRAMESET>" & @CR
$sHTML &= "</HTML>"
_IEDocWriteHTML ($oIE, $sHTML)
_IEAction ($oIE, "refresh")
Local $oFrameTop = _IEFrameGetObjByName ($oIE, "Top")
Local $oFrameMenu = _IEFrameGetObjByName ($oIE, "Menu")
Local $oFrameMain = _IEFrameGetObjByName ($oIE, "Main")
_IEBodyWriteHTML ($oFrameTop, '$oFrameTop = _IEFrameGetObjByName($oIE, "Top")')
_IEBodyWriteHTML ($oFrameMenu, '$oFrameMenu = _IEFrameGetObjByName($oIE, "Menu")')
_IEBodyWriteHTML ($oFrameMain, '$oFrameMain = _IEFrameGetObjByName($oIE, "Main")')


Function _IEErrorHandlerDeRegister

Function Reference

_IEErrorHandlerDeRegister

Disable a registered user COM error handler

#include <IE.au3>
_IEErrorHandlerDeRegister ( )

Parameters

None.

Return Value

Success: | Returns 1
Failure: | None

Remarks

See remarks for _IEErrorHandlerRegister.

Related

_IEErrorHandlerRegister

Example

; *******************************************************
; Example 1 - Register and later deregister a custom error handler
; *******************************************************
;
#include <IE.au3>
; Register a customer error handler
_IEErrorHandlerRegister ("MyErrFunc")
; Do something
; Deregister the customer error handler
_IEErrorHandlerDeregister ()
; Do something else

Exit

Func MyErrFunc()
$HexNumber = Hex($oIEErrorHandler.number, 8)
MsgBox(0, "", "We intercepted a COM Error !" & @CRLF & _
"Number is: " & $HexNumber & @CRLF & _
"Windescription is: " & $oIEErrorHandler.windescription)
SetError(1) ; something to check for when this function returns
EndFunc ;==>MyErrFunc


Function _IEErrorHandlerRegister

Function Reference

_IEErrorHandlerRegister

Register and enable a user COM error handler

#include <IE.au3>
_IEErrorHandlerRegister ( [$s_functionName = "__IEInternalErrorHandler"] )

Parameters

$s_functionName String variable with the name of a user-defined COM error handler, defaults to the internal COM error handler in this UDF

Return Value

Success: | Returns 1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 1 ($_IEStatus_GeneralError) = General Error
@Extended: | Contains invalid parameter number

Remarks

Important: When using your own error handler, the Error Object variable used MUST be named $oIEErrorHandler (see example).

AutoIt has the ability to trap COM errors and pass them through a custom error handler using the ObjEvent function. There is a problem with this for UDF writers however because only a single COM error handler can be in use at a time. For the UDF to use a COM error handler it must first deregister the user error handler, install its own and then put the user handler back in place. Unfortunately, by default, the UDF has no way to access the handle of the user error handler.

Using this routine you can register your COM error handler in a way that IE.au3 can gracefully remove and reinstate it when it needs to. You may either point to your own custom error handler or you may use the one developed for IE.au3 (the default). Using the default IE.au3 error handler you will also get some nice diagnostic information written to the console and some global variables that contain information about the trapped errors.

If you instantiate your own COM error handler without using this routine IE.au3 will not be able to trap some COM errors and you may experience some abrupt script terminations as a result.

If you use the default error handler (__IEInternalErrorHandler), the following global variables are set for you to reference: $IEComErrorNumber, $IEComErrorNumberHex, $IEComErrorDescription, $IEComErrorScriptline, $IEComErrorWinDescription, $IEComErrorSource, $IEComErrorHelpFile, $IEComErrorHelpContext, $IEComErrorLastDllError, $IEComErrorComObj and $IEComErrorOutput

You may control the display of COM error messages to the console with _IEErrorNotify.

Related

_IEErrorHandlerDeRegister, _IEErrorNotify

Example

; *******************************************************
; Example 1 - Register and later deregister a custom and the default IE.au3 error handler
; *******************************************************
;
#include <IE.au3>
; Register a customer error handler
_IEErrorHandlerRegister ("MyErrFunc")
; Do something
; Deregister the customer error handler
_IEErrorHandlerDeregister ()
; Do something else
; Register the default IE.au3 COM Error Handler
_IEErrorHandlerRegister ()
; Do more work

Exit

Func MyErrFunc()
; Important: the error object variable MUST be named $oIEErrorHandler
$ErrorScriptline = $oIEErrorHandler.scriptline
$ErrorNumber = $oIEErrorHandler.number
$ErrorNumberHex = Hex($oIEErrorHandler.number, 8)
$ErrorDescription = StringStripWS($oIEErrorHandler.description, 2)
$ErrorWinDescription = StringStripWS($oIEErrorHandler.WinDescription, 2)
$ErrorSource = $oIEErrorHandler.Source
$ErrorHelpFile = $oIEErrorHandler.HelpFile
$ErrorHelpContext = $oIEErrorHandler.HelpContext
$ErrorLastDllError = $oIEErrorHandler.LastDllError
$ErrorOutput = ""
$ErrorOutput &= "--> COM Error Encountered in " & @ScriptName & @CR
$ErrorOutput &= "----> $ErrorScriptline = " & $ErrorScriptline & @CR
$ErrorOutput &= "----> $ErrorNumberHex = " & $ErrorNumberHex & @CR
$ErrorOutput &= "----> $ErrorNumber = " & $ErrorNumber & @CR
$ErrorOutput &= "----> $ErrorWinDescription = " & $ErrorWinDescription & @CR
$ErrorOutput &= "----> $ErrorDescription = " & $ErrorDescription & @CR
$ErrorOutput &= "----> $ErrorSource = " & $ErrorSource & @CR
$ErrorOutput &= "----> $ErrorHelpFile = " & $ErrorHelpFile & @CR
$ErrorOutput &= "----> $ErrorHelpContext = " & $ErrorHelpContext & @CR
$ErrorOutput &= "----> $ErrorLastDllError = " & $ErrorLastDllError
MsgBox(0,"COM Error", $ErrorOutput)
SetError(1)
Return
EndFunc ;==>MyErrFunc


Function _IEErrorNotify

Function Reference

_IEErrorNotify

Specifies whether IE.au3 automatically notifies of Warnings and Errors (to the console)

#include <IE.au3>
_IEErrorNotify ( [$f_notify = -1] )

Parameters

$f_notify Optional: specifies whether notification should be on or off
-1 = (Default) return current setting
True = Turn On
False = Turn Off

Return Value

Success: | If $f_notify = -1, returns the current notification setting, else returns 1
Failure: | Returns 0

Remarks

IE.au3 writes diagnostic information, warnings and errors to the console by default. This information can readily be seen when using the SciTe editor to run your scripts.

This function allows you to turn this functionality on or off.

Related

None.

Example

; *******************************************************
; Example 1 - Check the current status of _IEErrorNotify, turn it off if on, on if off
; *******************************************************
;
#include <IE.au3>
If _IEErrorNotify () Then
MsgBox(0, "_IEErrorNotify Status", "Notification is ON, turning it OFF")
_IEErrorNotify (False)
Else
MsgBox(0, "_IEErrorNotify Status", "Notification is OFF, turning it ON")
_IEErrorNotify (True)
EndIf


Function _IEFormElementCheckBoxSelect

Function Reference

_IEFormElementCheckBoxSelect

Set the value of a specified form element.

#include <IE.au3>
_IEFormElementCheckBoxSelect ( ByRef $o_object, $s_string [, $s_name = "" [, $f_select = 1 [, $s_mode = "byValue" [, $f_fireEvent = 1]]]] )

Parameters

$o_object | Object variable of an InternetExplorer.Application, Form object
$s_string | Value used to match element - treatment based on $s_mode
$s_name | Optional: Name or Id of checkbox(es)
$f_select | Optional: specifies whether element should be checked or unchecked -1 = Return checked state 0 = Uncheck the element 1 = (Default) Check the element
$s_mode | Optional: specify search mode byValue = (Default) value of the checkbox you wish to select byIndex = 0-based index of checkbox you wish to select
$f_fireEvent | Optional: specifies whether to fire OnChange and OnClick events after changing value 0 = do not fire OnChange or OnClick event after setting value 1 = (Default) fire OnChange and OnClick events after setting value

Return Value

Success: | If $f_select = -1, returns the current checked state, else returns 1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
 | 5 ($_IEStatus_InvalidValue) = Invalid Value
 | 7 ($_IEStatus_NoMatch) = No Match
@Extended: | Contains invalid parameter number

Remarks

The $f_fireEvent parameter is significant only if the form element has an onChange event associated with it.

$s_Name is optional for this function. If it is omitted, the function will operate on a collection of all <input type=checkbox> elements in the form. If specified, the function will operate on a collection of <input type=checkbox> elements with that name.

Related

_IEFormElementOptionSelect, _IEFormElementRadioSelect

Example

; *******************************************************
; Example 1 - Open a browser with the form example, get reference to form, select and
; deselect the checkboxes byValue. Since $s_Name is not specified, operate
; on the collection of all <input type=checkbox> elements in the form
; Note: You will likely need to scroll down on the page to see the changes
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("form")
$oForm = _IEFormGetObjByName ($oIE, "ExampleForm")
For $i = 1 To 5
_IEFormElementCheckboxSelect ($oForm, "gameBasketball", "", 1, "byValue")
Sleep(1000)
_IEFormElementCheckboxSelect ($oForm, "gameFootball", "", 1, "byValue")
Sleep(1000)
_IEFormElementCheckboxSelect ($oForm, "gameTennis", "", 1, "byValue")
Sleep(1000)
_IEFormElementCheckboxSelect ($oForm, "gameBaseball", "", 1, "byValue")
Sleep(1000)
_IEFormElementCheckboxSelect ($oForm, "gameBasketball", "", 0, "byValue")
Sleep(1000)
_IEFormElementCheckboxSelect ($oForm, "gameFootball", "", 0, "byValue")
Sleep(1000)
_IEFormElementCheckboxSelect ($oForm, "gameTennis", "", 0, "byValue")
Sleep(1000)
_IEFormElementCheckboxSelect ($oForm, "gameBaseball", "", 0, "byValue")
Sleep(1000)
Next

; *******************************************************
; Example 2 - Open a browser with the form example, get reference to form, select and
; deselect the checkboxes byIndex. Since $s_Name is not specified, operate
; on the collection of all <input type=checkbox> elements in the form
; Note: You will likely need to scroll down on the page to see the changes
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("form")
$oForm = _IEFormGetObjByName ($oIE, "ExampleForm")
For $i = 1 To 5
_IEFormElementCheckboxSelect ($oForm, 3, "", 1, "byIndex")
Sleep(1000)
_IEFormElementCheckboxSelect ($oForm, 2, "", 1, "byIndex")
Sleep(1000)
_IEFormElementCheckboxSelect ($oForm, 1, "", 1, "byIndex")
Sleep(1000)
_IEFormElementCheckboxSelect ($oForm, 0, "", 1, "byIndex")
Sleep(1000)
_IEFormElementCheckboxSelect ($oForm, 3, "", 0, "byIndex")
Sleep(1000)
_IEFormElementCheckboxSelect ($oForm, 2, "", 0, "byIndex")
Sleep(1000)
_IEFormElementCheckboxSelect ($oForm, 1, "", 0, "byIndex")
Sleep(1000)
_IEFormElementCheckboxSelect ($oForm, 0, "", 0, "byIndex")
Sleep(1000)
Next

; *******************************************************
; Example 3 - Open a browser with the form example, get reference to form, select and
; deselect the checkboxes byIndex in the group that shares the name checkboxG2Example
; Note: You will likely need to scroll down on the page to see the changes
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("form")
$oForm = _IEFormGetObjByName ($oIE, "ExampleForm")
For $i = 1 To 5
_IEFormElementCheckboxSelect ($oForm, 0, "checkboxG2Example", 1, "byIndex")
Sleep(1000)
_IEFormElementCheckboxSelect ($oForm, 1, "checkboxG2Example", 1, "byIndex")
Sleep(1000)
_IEFormElementCheckboxSelect ($oForm, 0, "checkboxG2Example", 0, "byIndex")
Sleep(1000)
_IEFormElementCheckboxSelect ($oForm, 1, "checkboxG2Example", 0, "byIndex")
Sleep(1000)
Next


Function _IEFormElementGetCollection

Function Reference

_IEFormElementGetCollection

Returns a collection object variable representing all Form Elements within a given Form.

#include <IE.au3>
_IEFormElementGetCollection ( ByRef $o_object [, $i_index = -1] )

Parameters

$o_object | Object variable of an InternetExplorer.Application, Form object
$i_index | Optional: specifies whether to return a collection or indexed instance 0 or positive integer returns an indexed instance -1 = (Default) returns a collection

Return Value

Success: | Returns an object variable containing the Form Elements collection, @EXTENDED = form element count
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
 | 5 ($_IEStatus_InvalidValue) = Invalid Value
 | 7 ($_IEStatus_NoMatch) = No Match
@Extended: | Contains invalid parameter number

Remarks

None.

Related

None.

Example

; *******************************************************
; Example 1 - Get a reference to a specific form element by 0-based index.
; In this case, submit a query to the Google search engine
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("http://www.google.com")
$oForm = _IEFormGetCollection ($oIE, 0)
$oQuery = _IEFormElementGetCollection ($oForm, 1)
_IEFormElementSetValue ($oQuery, "AutoIt IE.au3")
_IEFormSubmit ($oForm)


Function _IEFormElementGetObjByName

Function Reference

_IEFormElementGetObjByName

Returns an object reference to a Form Element by name.

#include <IE.au3>
_IEFormElementGetObjByName ( ByRef $o_object, $s_name [, $i_index = 0] )

Parameters

$o_object | Object variable of an InternetExplorer.Application, Form object
$s_name | Specifies the name of the Form Element you wish to match
$i_index | Optional: If the Form Element name occurs more than once, specifies instance by 0-based index 0 (Default) or positive integer returns an indexed instance -1 returns a collection of the specified Form Elements

Return Value

Success: | Returns an object variable pointing to the Form Element object, @EXTENDED = form count
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
 | 7 ($_IEStatus_NoMatch) = No Match
@Extended: | Contains invalid parameter number

Remarks

If the desired form element does not have a name or ID, _IEFormElementGetCollection to get a reference by index

Related

_IEFormElementGetCollection

Example

; *******************************************************
; Example 1 - Get a reference to a specific form element by name.
; In this case, submit a query to the Google search engine
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("http://www.google.com")
$oForm = _IEFormGetObjByName ($oIE, "f")
$oQuery = _IEFormElementGetObjByName ($oForm, "q")
_IEFormElementSetValue ($oQuery, "AutoIt IE.au3")
_IEFormSubmit ($oForm)


Function _IEFormElementGetValue

Function Reference

_IEFormElementGetValue

Returns the value of a given Form Element.

#include <IE.au3>
_IEFormElementGetValue ( ByRef $o_object )

Parameters

$o_object Object variable of an InternetExplorer.Application, Form Element object

Return Value

Success: | Returns the string value of the given Form Element
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
@Extended: | Contains invalid parameter number

Remarks

See remarks for _IEFormElementSetValue.

Related

_IEFormElementSetValue, _IEFormElementGetCollection, _IEFormElementGetObjByName, _IEFormElementOptionSelect, _IEFormElementCheckboxSelect, _IEFormElementRadioSelect

Example

; *******************************************************
; Example 1 - Open a browser with the form example, set the value of a text
; form element, retrieve and display the value from the element
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("form")
$oForm = _IEFormGetObjByName ($oIE, "ExampleForm")
$oText = _IEFormElementGetObjByName ($oForm, "textExample")
$IEAu3Version = _IE_VersionInfo ()
_IEFormElementSetValue ($oText, $IEAu3Version[5])
MsgBox(0, "Form Element Value", _IEFormElementGetValue ($oText))


Function _IEFormElementOptionSelect

Function Reference

_IEFormElementOptionSelect

Set the value of a specified form element.

#include <IE.au3>
_IEFormElementOptionSelect ( ByRef $o_object, $s_string [, $f_select = 1 [, $s_mode = "byValue" [, $f_fireEvent = 1]]] )

Parameters

$o_object | Form Element Object of type "Select Option"
$s_string | Value used to match element - treatment based on $s_mode
$f_select | Optional: specifies whether element should be selected or deselected -1 = Return selected state 0 = Deselect the element 1 = (Default) Select the element
$s_mode | Optional: specifies search mode byValue = (Default) value of the option you wish to select byText = text of the option you wish to select byIndex = 0-based index of option you wish to select
$f_fireEvent | Optional: specifies whether to fire OnChange and OnClick events after changing value 0 = do not fire OnChange or OnClick event after setting value 1 = (Default) fire OnChange and OnClick events after setting value

Return Value

Success: | If $f_select = -1, returns the current selected state, else returns 1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
 | 5 ($_IEStatus_InvalidValue) = Invalid Value
 | 7 ($_IEStatus_NoMatch) = No Match
@Extended: | Contains invalid parameter number

Remarks

The $f_fireEvent parameter is significant only if the form element has an onChange event associated with it.

Related

_IEFormElementCheckBoxSelect, _IEFormElementRadioSelect

Example

; *******************************************************
; Example 1 - Open a browser with the form example, get reference to form, get reference
; to select element, cycle 10 times selecting options byValue, byText and byIndex
; Note: You will likely need to scroll down on the page to see the changes
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("form")
$oForm = _IEFormGetObjByName ($oIE, "ExampleForm")
$oSelect = _IEFormElementGetObjByName ($oForm, "selectExample")
For $i = 1 To 10
_IEFormElementOptionSelect ($oSelect, "Freepage", 1, "byText")
Sleep(1000)
_IEFormElementOptionSelect ($oSelect, "midipage.html", 1, "byValue")
Sleep(1000)
_IEFormElementOptionSelect ($oSelect, 0, 1, "byIndex")
Sleep(1000)
Next

; *******************************************************
; Example 2 - Open a browser with the form example, get reference to form, get reference
; to select multiple element, cycle 5 times selecting and then deselecting
; options byValue, byText and byIndex.
; Note: You will likely need to scroll down on the page to see the changes
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("form")
$oForm = _IEFormGetObjByName ($oIE, "ExampleForm")
$oSelect = _IEFormElementGetObjByName ($oForm, "multipleSelectExample")
For $i = 1 To 5
_IEFormElementOptionSelect ($oSelect, "Carlos", 1, "byText")
Sleep(1000)
_IEFormElementOptionSelect ($oSelect, "Name2", 1, "byValue")
Sleep(1000)
_IEFormElementOptionSelect ($oSelect, 5, 1, "byIndex")
Sleep(1000)
_IEFormElementOptionSelect ($oSelect, "Carlos", 0, "byText")
Sleep(1000)
_IEFormElementOptionSelect ($oSelect, "Name2", 0, "byValue")
Sleep(1000)
_IEFormElementOptionSelect ($oSelect, 5, 0, "byIndex")
Sleep(1000)
Next

; *******************************************************
; Example 3 - Open a browser with the form example, get reference to form, get reference
; to select element, check to see if the option "Freepage" is selected and
; report result. Repeat for the option with index 0 and for the option
; with value of 'midipage.html'
; Note: You will likely need to scroll down on the page to see the changes
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("form")
$oForm = _IEFormGetObjByName ($oIE, "ExampleForm")
$oSelect = _IEFormElementGetObjByName ($oForm, "selectExample")
If _IEFormElementOptionSelect ($oSelect, "Freepage", -1, "byText") Then
MsgBox(0, "Option Selected", "Option Freepage is selected")
Else
MsgBox(0, "Option Selected", "Option Freepage is Not selected")
EndIf
If _IEFormElementOptionSelect ($oSelect, 0, -1, "byIndex") Then
MsgBox(0, "Option Selected", "The First (index 0) option is selected")
Else
MsgBox(0, "Option Selected", "The First (index 0) option is Not selected")
EndIf
If _IEFormElementOptionSelect ($oSelect, "midipage.html", -1, "byValue") Then
MsgBox(0, "Option Selected", "The option with value 'midipage.html' is selected")
Else
MsgBox(0, "Option Selected", "The option with value 'midipage.html' is NOT selected")
EndIf


Function _IEFormElementRadioSelect

Function Reference

_IEFormElementRadioSelect

Set the value of a specified form element.

#include <IE.au3>
_IEFormElementRadioSelect ( ByRef $o_object, $s_string , $s_name [, $f_select = 1 [, $s_mode = "byValue" [, $f_fireEvent = 1]]] )

Parameters

$o_object | Object variable of an InternetExplorer.Application, Form object
$s_string | Value used to match element - treatment based on $s_mode
$s_name | Name or Id of Radio Group
$f_select | Optional: specifies whether element should be selected or deselected -1 = Return selected state 0 = Unselect the element 1 = (Default) Select the element
$s_mode | Optional: specifies search mode byValue = (Default) value of the radio you wish to select byIndex = 0-based index of radio you wish to select
$f_fireEvent | Optional: specifies whether to fire OnChange and OnClick events after changing value 0 = do not fire OnChange or OnClick event after setting value 1 = (Default) fire OnChange and OnClick events after setting value

Return Value

Success: | If $f_select = -1, returns the current selected state, else returns 1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
 | 5 ($_IEStatus_InvalidValue) = Invalid Value
 | 7 ($_IEStatus_NoMatch) = No Match
@Extended: | Contains invalid parameter number

Remarks

The $f_fireEvent parameter is significant only if the form element has an onChange event associated with it.

$s_Name is a mandatory parameter for this function. Radio buttons are operated upon in groups sharing the same name. No more than one element within a group may be selected at a given time - when one item is selected, all others are deselected.

Related

_IEFormElementOptionSelect, _IEFormElementCheckBoxSelect

Example

; *******************************************************
; Example 1 - Open a browser with the form example, get reference to form, select
; each radio button byValue, then deselect the last item leaving none selected.
; Note: You will likely need to scroll down on the page to see the changes
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("form")
$oForm = _IEFormGetObjByName ($oIE, "ExampleForm")
For $i = 1 To 5
_IEFormElementRadioSelect ($oForm, "vehicleAirplane", "radioExample", 1, "byValue")
Sleep(1000)
_IEFormElementRadioSelect ($oForm, "vehicleTrain", "radioExample", 1, "byValue")
Sleep(1000)
_IEFormElementRadioSelect ($oForm, "vehicleBoat", "radioExample", 1, "byValue")
Sleep(1000)
_IEFormElementRadioSelect ($oForm, "vehicleCar", "radioExample", 1, "byValue")
Sleep(1000)
_IEFormElementRadioSelect ($oForm, "vehicleCar", "radioExample", 0, "byValue")
Sleep(1000)
Next

; *******************************************************
; Example 2 - Open a browser with the form example, get reference to form, select
; each radio button byIndex, then deselect the last item leaving none selected.
; Note: You will likely need to scroll down on the page to see the changes
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("form")
$oForm = _IEFormGetObjByName ($oIE, "ExampleForm")
For $i = 1 To 5
_IEFormElementRadioSelect ($oForm, 3, "radioExample", 1, "byIndex")
Sleep(1000)
_IEFormElementRadioSelect ($oForm, 2, "radioExample", 1, "byIndex")
Sleep(1000)
_IEFormElementRadioSelect ($oForm, 1, "radioExample", 1, "byIndex")
Sleep(1000)
_IEFormElementRadioSelect ($oForm, 0, "radioExample", 1, "byIndex")
Sleep(1000)
_IEFormElementRadioSelect ($oForm, 0, "radioExample", 0, "byIndex")
Sleep(1000)
Next


Function _IEFormElementSetValue

Function Reference

_IEFormElementSetValue

Set the value of a specified Form Element.

#include <IE.au3>
_IEFormElementSetValue ( ByRef $o_object, $s_newvalue [, $f_fireEvent = 1] )

Parameters

$o_object | Object variable of an InternetExplorer.Application, Form Element object
$s_newvalue | The new value to be set into the Form Element
$f_fireEvent | Optional: specifies whether to fire an OnChange event after changing value 0 = Do not fire OnChange or OnClick event after setting value 1 = (Default) fire OnChange and OnClick event after setting value

Return Value

Success: | Returns 1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
@Extended: | Contains invalid parameter number

Remarks

While all Form Elements have a value, only text oriented elements use their value attribute in an obvious fashion (type text, textarea, hidden, password and file). The value of other form elements does not affect what is displayed in the user interface, but rather the value that is returned by the element when it is selected or activated.

See _IEFormElementOptionSelect, _IEFormElementCheckboxSelect, _IEFormElementRadioSelect and _IEFormImageClick for more information.

Note: You cannot use _IEFormElementSetValue to set the value of an INPUT TYPE=FILE element. Browser security restrictions prevent this element from being scripted. See the example below for a workaround.

Related

_IEFormElementGetValue, _IEFormElementGetCollection, _IEFormElementGetObjByName, _IEFormElementOptionSelect, _IEFormElementCheckboxSelect, _IEFormElementRadioSelect

Example

; *******************************************************
; Example 1 - Open a browser with the form example, set the value of a text form element
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("form")
$oForm = _IEFormGetObjByName ($oIE, "ExampleForm")
$oText = _IEFormElementGetObjByName ($oForm, "textExample")
_IEFormElementSetValue ($oText, "Hey! This works!")

; *******************************************************
; Example 2 - Get a reference to a specific form element and set its value.
; In this case, submit a query to the Google search engine
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("http://www.google.com")
$oForm = _IEFormGetObjByName ($oIE, "f")
$oQuery = _IEFormElementGetObjByName ($oForm, "q")
_IEFormElementSetValue ($oQuery, "AutoIt IE.au3")
_IEFormSubmit ($oForm)

; *******************************************************
; Example 3 - Login to Hotmail
; *******************************************************
;
#include <IE.au3>
; Create a browser window and navigate to hotmail
$oIE = _IECreate ("http://www.hotmail.com")

; get pointers to the login form and username, password and signin fields
$o_form = _IEFormGetObjByName ($oIE, "f1")
$o_login = _IEFormElementGetObjByName ($o_form, "login")
$o_password = _IEFormElementGetObjByName ($o_form, "passwd")
$o_signin = _IEFormElementGetObjByName ($o_form, "SI")

$username = "your username here"
$password = "your password here"

; Set field values and submit the form
_IEFormElementSetValue ($o_login, $username)
_IEFormElementSetValue ($o_password, $password)
_IEAction ($o_signin, "click")

; *******************************************************
; Example 4 - Set the value of an INPUT TYPE=FILE element
; (security restrictions prevent using _IEFormElementSetValue)
; *******************************************************
;
#include <IE.au3>

$oIE = _IE_Example("form")
$oForm = _IEFormGetObjByName($oIE, "ExampleForm")
$oInputFile = _IEFormElementGetObjByName($oForm, "fileExample")

; Assign input focus to the field and then send the text string
_IEAction($oInputFile, "focus")
Send("C:\myfile.txt")

; *******************************************************
; Example 5 - Set the value of an INPUT TYPE=FILE element
; Same as previous example, but with invisible window
; (security restrictions prevent using _IEFormElementSetValue)
; *******************************************************
;
#include <IE.au3>

$oIE = _IE_Example("form")

; Hide the browser window to demonstrate sending text to invisible window
_IEAction($oIE, "invisible")

$oForm = _IEFormGetObjByName($oIE, "ExampleForm")
$oInputFile = _IEFormElementGetObjByName($oForm, "fileExample")

; Assign input focus to the field and then send the text string
_IEAction($oInputFile, "focus")
$hIE = _IEPropertyGet($oIE, "hwnd")
ControlSend($hIE, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "C:\myfile.txt")

MsgBox(0, "Success", "Value set to C:\myfile.txt")
_IEAction($oIE, "visible")


Function _IEFormGetCollection

Function Reference

_IEFormGetCollection

Returns a collection object variable representing the Forms in the document or a single form by index.

#include <IE.au3>
_IEFormGetCollection ( ByRef $o_object [, $i_index = -1] )

Parameters

$o_object | Object variable of an InternetExplorer.Application, Window, Frame or iFrame object
$i_index | Optional: specifies whether to return a collection or indexed instance 0 or positive integer returns an indexed instance -1 = (Default) returns a collection

Return Value

Success: | Returns an object variable with a collection of all forms in the document, @EXTENDED = form count
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 5 ($_IEStatus_InvalidValue) = Invalid Value
 | 7 ($_IEStatus_NoMatch) = No Match
@Extended: | Contains invalid parameter number

Remarks

None.

Related

None.

Example

; *******************************************************
; Example 1 - Get a reference to a specific form by 0-based index,
; in this case the first form on the page
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("http://www.google.com")
$oForm = _IEFormGetCollection ($oIE, 0)
$oQuery = _IEFormElementGetCollection ($oForm, 1)
_IEFormElementSetValue ($oQuery, "AutoIt IE.au3")
_IEFormSubmit ($oForm)

; *******************************************************
; Example 2 - Get a reference to the collection of forms on a page,
; and then loop through them displaying information for each
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("http://www.autoitscript.com")
$oForms = _IEFormGetCollection ($oIE)
MsgBox(0, "Forms Info", "There are " & @extended & " forms on this page")
For $oForm In $oForms
MsgBox(0, "Form Info", $oForm.name)
Next

; *******************************************************
; Example 3 - Get a reference to the collection of forms on a page,
; and then loop through them displaying information for each
; demonstrating use of form index
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("http://www.autoitscript.com")
$oForms = _IEFormGetCollection ($oIE)
$iNumForms = @extended
MsgBox(0, "Forms Info", "There are " & $iNumForms & " forms on this page")
For $i = 0 to $iNumForms - 1
$oForm = _IEFormGetCollection ($oIE, $i)
MsgBox(0, "Form Info", $oForm.name)
Next


Function _IEFormGetObjByName

Function Reference

_IEFormGetObjByName

Returns an object reference to a Form by name.

#include <IE.au3>
_IEFormGetObjByName ( ByRef $o_object, $s_name [, $i_index = 0] )

Parameters

$o_object | Object variable of an InternetExplorer.Application, Window or Frame object
$s_name | Specifies the name of the Form you wish to match
$i_index | Optional: If Form name occurs more than once, specifies instance by 0-based index 0 (Default) or positive integer returns an indexed instance -1 returns a collection of the specified Forms

Return Value

Success: | Returns an object variable pointing to the Form object, @EXTENDED = form count
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 7 ($_IEStatus_NoMatch) = No Match
@Extended: | Contains invalid parameter number

Remarks

If the desired form does not have a name or ID, _IEFormGetCollection to get a reference by index

Related

_IEFormGetCollection

Example

; *******************************************************
; Example 1 - Get a reference to a specific form by name. In this case, submit a query
; to the Google search engine. Note that the names of the form and form
; elements can be found by viewing the page HTML source
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("http://www.google.com")
$oForm = _IEFormGetObjByName ($oIE, "f")
$oQuery = _IEFormElementGetObjByName ($oForm, "q")
_IEFormElementSetValue ($oQuery, "AutoIt IE.au3")
_IEFormSubmit ($oForm)


Function _IEFormImageClick

Function Reference

_IEFormImageClick

Simulate a mouse click on an <input type=image>. Match by sub-string match of alt text, name or src.

#include <IE.au3>
_IEFormImageClick ( ByRef $o_object, $s_linkText [, $s_mode = "src" [, $i_index = 0 [, $f_wait = 1]]] )

Parameters

$o_object | Object variable of any DOM element (will be converted to the associated document object)
$s_linkText | Value used to match element - treatment based on $s_mode
$s_mode | Optional: specifies search mode src = (Default) match the url of the image name = match the name of the image alt = match the alternate text of the image
$i_index | Optional: If the img text occurs more than once, specifies which instance you want by 0-based index
$f_wait | Optional: specifies whether to wait for page to load before returning 0 = Return immediately, not waiting for page to load 1 = (Default) Wait for page load to complete before returning

Return Value

Success: | Returns -1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 1 ($_IEStatus_GeneralError) = General Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
 | 5 ($_IEStatus_InvalidValue) = Invalid Value
 | 6 ($_IEStatus_LoadWaitTimeout) = Load Wait Timeout
 | 7 ($_IEStatus_NoMatch) = No Match
 | 8 ($_IEStatus_AccessIsDenied) = Access Is Denied
 | 9 ($_IEStatus_ClientDisconnected) = Client Disconnected
@Extended: | Contains invalid parameter number

Remarks

The <input type=image> form element is handled differently from all others. It is not recognized by Internet Explorer as a member of the form element collection and this function therefore gives you other means of getting a reference to it within the document using src, name or alt strings. Regardless of the object passed to this function, it looks for the form element within the full document context.

Related

_IEImgClick

Example

; *******************************************************
; Example 1 - Open a browser with the form example, click on the
; <input type=image> form element with matching alt text
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("form")
_IEFormImageClick ($oIE, "AutoIt Homepage", "alt")

; *******************************************************
; Example 2 - Open a browser with the form example, click on the <input type=image>
; form element with matching img source URL (sub-string)
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("form")
_IEFormImageClick ($oIE, "autoit_6_240x100.jpg", "src")

; *******************************************************
; Example 3 - Open a browser with the form example, click on the
; <input type=image> form element with matching name
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("form")
_IEFormImageClick ($oIE, "imageExample", "name")


Function _IEFormReset

Function Reference

_IEFormReset

Reset a specified Form setting the values back to their loaded defaults.

#include <IE.au3>
_IEFormReset ( ByRef $o_object )

Parameters

$o_object Object variable of an InternetExplorer.Application, Form object

Return Value

Success: | Returns 1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
@Extended: | Contains invalid parameter number

Remarks

None.

Related

_IEFormSubmit, _IEFormGetObjByName, _IEFormGetCollection

Example

; *******************************************************
; Example 1 - Open a browser with the form example, fill in a form field and
; reset the form back to default values
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("form")
$oForm = _IEFormGetObjByName ($oIE, "ExampleForm")
$oText = _IEFormElementGetObjByName ($oForm, "textExample")
_IEFormElementSetValue ($oText, "Hey! It works!")
_IEFormReset ($oForm)


Function _IEFormSubmit

Function Reference

_IEFormSubmit

Submit a specified Form.

#include <IE.au3>
_IEFormSubmit ( ByRef $o_object [, $f_wait = 1] )

Parameters

$o_object | Object variable of an InternetExplorer.Application, Form object
$f_wait | Optional: specifies whether to wait for page to load before returning 0 = Return immediately, not waiting for page to load 1 = (Default) Wait for page load to complete before returning

Return Value

Success: | Returns -1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 1 ($_IEStatus_GeneralError) = General Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
 | 6 ($_IEStatus_LoadWaitTimeout) = Load Wait Timeout
 | 8 ($_IEStatus_AccessIsDenied) = Access Is Denied
 | 9 ($_IEStatus_ClientDisconnected) = Client Disconnected
@Extended: | Contains invalid parameter number

Remarks

For many HTML forms it is not sufficient to use _IEFormSubmit() because there is often custom JavaScript tied to an onClick event for its Submit button. In these cases you'll need to simulate a click of the submit button instead of using _IEFormSubmit(). See the example for the "click" action of _IEAction().
As well, some form processing relies on the "value" of the submit button being passed along with the rest of the form data (often when there is more than one submit button in the form and they are designed to trigger different results). This function will not result in a submit button value being passed. The solution is to use the "click" action of _IEAction() as above.
If you experience trouble with the automatic _IELoadWait called by default, please set $f_wait parameter to 0 and call _IELoadWait from your script, passing it the InternetExplorer object.

Related

_IEFormReset, _IEFormGetObjByName, _IEFormGetCollection, _IEFormElementGetObjByName, _IEFormElementGetCollection, _IELoadWait

Example

; *******************************************************
; Example 1 - Open a browser with the form example, fill in a form field and submit the form
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("form")
$oForm = _IEFormGetObjByName ($oIE, "ExampleForm")
$oText = _IEFormElementGetObjByName ($oForm, "textExample")
_IEFormElementSetValue ($oText, "Hey! It works!")
_IEFormSubmit ($oForm)

; *******************************************************
; Example 2 - Get a reference to a specific form element and set its value.
; In this case, submit a query to the Google search engine
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("http://www.google.com")
$oForm = _IEFormGetObjByName ($oIE, "f")
$oQuery = _IEFormElementGetObjByName ($oForm, "q")
_IEFormElementSetValue ($oQuery, "AutoIt IE.au3")
_IEFormSubmit ($oForm)

; *******************************************************
; Example 3 - Get a reference to a specific form element and set its value.
; Call _IELoadWait manually if the default _IELoadWait experiences trouble.
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("http://www.google.com")
$oForm = _IEFormGetObjByName ($oIE, "f")
$oQuery = _IEFormElementGetObjByName ($oForm, "q")
_IEFormElementSetValue ($oQuery, "AutoIt IE.au3")
_IEFormSubmit ($oForm, 0)
_IELoadWait($oIE)


Function _IEFrameGetCollection

Function Reference

_IEFrameGetCollection

Returns a collection object containing the frames in a FrameSet or the iFrames on a normal page or a single Frame or iFrame by index.

#include <IE.au3>
_IEFrameGetCollection ( ByRef $o_object [, $i_index = -1] )

Parameters

$o_object | Object variable of an InternetExplorer.Application, Window or Frame object
$i_index | Optional: specifies whether to return a collection or indexed instance 0 or positive integer returns an indexed instance -1 = (Default) returns a collection

Return Value

Success: | Returns an object variable containing the Frames collection, @EXTENDED = Frame count
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 5 ($_IEStatus_InvalidValue) = Invalid Value
 | 7 ($_IEStatus_NoMatch) = No Match
@Extended: | Contains invalid parameter number

Remarks

Although MSDN documents the return value for this function as a collection object, it cannot be looped through with a For...Next loop like a standard collection object. You must instead step through the collection by index - see example.

Related

_IEIsFrameSet, _IEFrameGetObjByName

Example

; *******************************************************
; Example 1 - Open frameset example, get collection of frames
; and loop through them displaying their source URL's
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("frameset")
$oFrames = _IEFrameGetCollection ($oIE)
$iNumFrames = @extended
For $i = 0 to ($iNumFrames - 1)
$oFrame = _IEFrameGetCollection ($oIE, $i)
MsgBox(0, "Frame Info", _IEPropertyGet ($oFrame, "locationurl"))
Next


Function _IEFrameGetObjByName

Function Reference

_IEFrameGetObjByName

Returns an object reference to a Frame or iFrame by name.

#include <IE.au3>
_IEFrameGetObjByName ( ByRef $o_object, $s_name )

Parameters

$o_object | Object variable of an InternetExplorer.Application, Window or Frame object
$s_name | Name of the Frame you wish to match

Return Value

Success: | Returns an object variable pointing to the Window object in a Frame, @EXTENDED = Frame count
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
 | 7 ($_IEStatus_NoMatch) = No Match
@Extended: | Contains invalid parameter number

Remarks

The object returned by this function is a window object which allows access to the document contained within. You may also want to access the frame or iframe tag and its properties - to do this, use _IETagNameGetCollection.

Related

_IEFrameGetCollection

Example

; *******************************************************
; Example 1 - Open iFrame example, get a reference to the iFrame
; with a name of "iFrameTwo" and replace its body HTML
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("iframe")
$oFrame = _IEFrameGetObjByName ($oIE, "iFrameTwo")
_IEBodyWriteHTML ($oFrame, "Hello <b>iFrame!</b>")
_IELoadWait ($oFrame)


Function _IEGetObjById

Function Reference

_IEGetObjById

Returns an object variable by id or name.

#include <IE.au3>
_IEGetObjById ( ByRef $o_object, $s_Id)

Parameters

$o_object | Object variable of an InternetExplorer.Application, Window or Frame object
$s_Id | Specifies id or name of the object you wish to match

Return Value

Success: | Returns an object variable pointing to the specified Object
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 7 ($_IEStatus_NoMatch) = No Match

Remarks

This function will return an object reference to any object in the document with a specified id or name. DOM elements can have Name or ID attributes or both. A specific ID can be assigned to only a single element while a specific Name can be assigned to multiple elements. In Internet Explorer, the Name and ID namespaces are shared.

Related

_IEGetObjByName

Example

; *******************************************************
; Example 1 - Open a browser to the basic example, get an object reference
; to the DIV element with the ID "line1". Display the innerText
; of this element to the console.
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("basic")
$oDiv = _IEGetObjById ($oIE, "line1")
ConsoleWrite(_IEPropertyGet($oDiv, "innertext") & @CR)


Function _IEGetObjByName

Function Reference

_IEGetObjByName

Returns an object variable by name or id.

#include <IE.au3>
_IEGetObjByName ( ByRef $o_object, $s_Id [, $i_index = 0] )

Parameters

$o_object | Object variable of an InternetExplorer.Application, Window or Frame object
$s_Id | Specifies name or id of the object you wish to match
$i_index | Optional: If name of id occurs more than once, specifies instance by 0-based index 0 (Default) or positive integer returns an indexed instance -1 returns a collection of the specified objects

Return Value

Success: | Returns an object variable pointing to the specified Object, @EXTENDED = specified object count
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 7 ($_IEStatus_NoMatch) = No Match
@Extended: | Contains invalid parameter number

Remarks

This function will return an object reference to any object in the document with a specified name or id. DOM elements can have Name or ID attributes or both. A specific ID can be assigned to only a single element while a specific Name can be assigned to multiple elements. In Internet Explorer, the Name and ID namespaces are shared.

Related

_IEGetObjById

Example

; *******************************************************
; Example 1 - Open a browser to the form example, get an object reference
; to the element with the name "ExampleForm". In this case the
; result is identical to using $oForm = _IEFormGetObjByName($oIE, "ExampleForm")
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("form")
$oForm = _IEGetObjByName ($oIE, "ExampleForm")


Function _IEHeadInsertEventScript

Function Reference

_IEHeadInsertEventScript

Inserts a Javascript into the Head of the document.

#include <IE.au3>
_IEHeadInsertEventScript ( ByRef $o_object, $s_htmlFor, $s_event, $s_script )

Parameters

$o_object | Object variable of an InternetExplorer.Application, Window or Frame object
$s_htmlFor | The HTML element for event monitoring (e.g. "document" or an element ID)
$s_event | The event to monitor (e.g. "onclick" or "oncontextmenu")
$s_script | Javascript string to be executed

Return Value

Success: | Returns 1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
@Extended: | Contains invalid parameter number

Remarks

Using ObjEvent, AutoIt is able to be notified of events via COM, but it manages them asynchronously rather than synchronously as they are handled in the browser context. This routine allows you to inject code that is managed inside the browser context.

Related

_IEDocInsertHTML

Example

; *******************************************************
; Example 1 - Open a browser with the basic example page, insert an
; event script into the head of the document that creates
; a JavaScript alert when someone clicks on the document
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("basic")
_IEHeadInsertEventScript ($oIE, "document", "onclick", "alert('Someone clicked the document!');")

; *******************************************************
; Example 2 - Open a browser with the basic example page, insert an
; event script into the head of the document that creates
; a JavaScript alert when someone tries to right-click on the
; document and then the event script returns "false" to prevent
; the right-click context menu from appearing
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("basic")
_IEHeadInsertEventScript ($oIE, "document", "oncontextmenu", "alert('No Context Menu');return false")

; *******************************************************
; Example 3 - Open a browser with the basic example page, insert an
; event script into the head of the document that creates a
; JavaScript alert when we are about to navigate away from the
; page and presents the option to cancel the operation.
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("basic")
_IEHeadInsertEventScript ($oIE, "window", "onbeforeunload", _
"alert('Example warning follows...');return 'Pending changes may be lost';")
_IENavigate($oIE, "www.autoitscript.com")


Function _IEImgClick

Function Reference

_IEImgClick

Simulate a mouse click on an image. Match by sub-string match of alt text, name, or src.

#include <IE.au3>
_IEImgClick ( ByRef $o_object, $s_linkText [, $s_mode = "src" [, $i_index = 0 [, $f_wait = 1]]] )

Parameters

$o_object | Object variable of an InternetExplorer.Application, Window or Frame object
$s_linkText | Text to match the content of the attribute specified in $s_mode
$s_mode | Optional: specifies search mode src = (Default) match the url of the image name = match the name of the image alt = match the alternate text of the image
$i_index | Optional: If the img text occurs more than once, specify which instance you want by 0-based index
$f_wait | Optional: specifies whether to wait for page to load before returning 0 = Return immediately, not waiting for page to load 1 = (Default) Wait for page load to complete before returning

Return Value

Success: | Returns -1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 1 ($_IEStatus_GeneralError) = General Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
 | 5 ($_IEStatus_InvalidValue) = Invalid Value
 | 6 ($_IEStatus_LoadWaitTimeout) = Load Wait Timeout
 | 7 ($_IEStatus_NoMatch) = No Match
 | 8 ($_IEStatus_AccessIsDenied) = Access Is Denied
 | 9 ($_IEStatus_ClientDisconnected) = Client Disconnected
@Extended: | Contains invalid parameter number

Remarks

None.

Related

_IEImgGetCollection, _IEFormImageClick

Example

; *******************************************************
; Example 1 - Click on IMG by Alt text
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("basic")
_IEImgClick ($oIE, "AutoIt Homepage Image", "alt")

; *******************************************************
; Example 2 - Click on IMG by name
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("basic")
_IEImgClick ($oIE, "AutoItImage", "name")

; *******************************************************
; Example 3 - Click on IMG by src sub-string
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("basic")
_IEImgClick ($oIE, "autoit_6_240x100.jpg", "src")

; *******************************************************
; Example 4 - Click on IMG by full src string
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("basic")
_IEImgClick ($oIE, "http://www.autoitscript.com/images/autoit_6_240x100.jpg")


Function _IEImgGetCollection

Function Reference

_IEImgGetCollection

Returns a collection object variable representing the IMG tags in the document or a single image by index.

#include <IE.au3>
_IEImgGetCollection ( ByRef $o_object [, $i_index = -1] )

Parameters

$o_object | Object variable of an InternetExplorer.Application, Window, Frame or iFrame object
$i_index | Optional: specifies whether to return a collection or indexed instance 0 or positive integer returns an indexed instance -1 = (Default) returns a collection

Return Value

Success: | Returns an object variable with a collection of all IMG tags in the document, @EXTENDED = img count
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 5 ($_IEStatus_InvalidValue) = Invalid Value
 | 7 ($_IEStatus_NoMatch) = No Match
@Extended: | Contains invalid parameter number

Remarks

None.

Related

_IEFormImageClick

Example

; *******************************************************
; Example 1 - Create browser at AutoIt homepage, get a reference to
; the 6th Image on the page (note: the first image is index 0)
; and display information about it
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("http://www.autoitscript.com/")
$oImg = _IEImgGetCollection ($oIE, 5)
$sInfo = "Src: " & $oImg.src & @CR
$sInfo &= "FileName: " & $oImg.nameProp & @CR
$sInfo &= "Height: " & $oImg.height & @CR
$sInfo &= "Width: " & $oImg.width & @CR
$sInfo &= "Border: " & $oImg.border
MsgBox(0, "4th Image Info", $sInfo)

; *******************************************************
; Example 2 - Create browser at AutoIt homepage, get Img collection
; and display src URL for each
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("http://www.autoitscript.com/")
$oImgs = _IEImgGetCollection ($oIE)
$iNumImg = @extended
MsgBox(0, "Img Info", "There are " & $iNumImg & " images on the page")
For $oImg In $oImgs
MsgBox(0, "Img Info", "src=" & $oImg.src)
Next


Function _IEIsFrameSet

Function Reference

_IEIsFrameSet

Checks to see if the specified Window contains a FrameSet.

#include <IE.au3>
_IEIsFrameSet ( ByRef $o_object )

Parameters

$o_object Object variable of an InternetExplorer.Application, Window or Frame object

Return Value

Success: | Returns 1 if the object references a FrameSet page
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
@Extended: | Contains invalid parameter number

Remarks

_IEFrameGetCollection does not specify whether the referenced frames are part of a FrameSet or whether they are iFrames. If frames exist on a page and this function return False, then the frames are iFrames.

Related

_IEFrameGetCollection

Example

; *******************************************************
; Example 1 - Display the frameset example, get frame collection,
; check number of frames, display number of frames or iFrames present
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("frameset")
$oFrames = _IEFrameGetCollection ($oIE)
$iNumFrames = @extended
If $iNumFrames > 0 Then
If _IEIsFrameSet ($oIE) Then
MsgBox(0, "Frame Info", "Page contains " & $iNumFrames & " frames in a FrameSet")
Else
MsgBox(0, "Frame Info", "Page contains " & $iNumFrames & " iFrames")
EndIf
Else
MsgBox(0, "Frame Info", "Page contains no frames")
EndIf


Function _IELinkClickByIndex

Function Reference

_IELinkClickByIndex

Simulate a mouse click on a link by 0-based index (in source order).

#include <IE.au3>
_IELinkClickByIndex ( ByRef $o_object, $i_index [, $f_wait = 1] )

Parameters

$o_object | Object variable of an InternetExplorer.Application, Window or Frame object
$i_index | Optional: 0-based index of the link you wish to match
$f_wait | Optional: specifies whether to wait for page to load before returning 0 = Return immediately, not waiting for page to load 1 = (Default) Wait for page load to complete before returning

Return Value

Success: | Returns -1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 1 ($_IEStatus_GeneralError) = General Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
 | 6 ($_IEStatus_LoadWaitTimeout) = Load Wait Timeout
 | 7 ($_IEStatus_NoMatch) = No Match
 | 8 ($_IEStatus_AccessIsDenied) = Access Is Denied
 | 9 ($_IEStatus_ClientDisconnected) = Client Disconnected
@Extended: | Contains invalid parameter number

Remarks

Not all elements that appear to be links actually are. It is common practice to attach onClick JavaScript events to other DOM elements to simulate the behavior of links. To activate such elements, use "click" with _IEAction.

Related

_IELinkClickByText, _IELoadWait

Example

; *******************************************************
; Example 1 - Open browser with basic example, click on the 3rd
; link on the page (note: the first link is index 0)
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("basic")
_IELinkClickByIndex ($oIE, 2)


Function _IELinkClickByText

Function Reference

_IELinkClickByText

Simulate a mouse click on a link with text sub-string matching the string provided.

#include <IE.au3>
_IELinkClickByText ( ByRef $o_object, $s_linkText [, $i_index = 0], $f_wait = 1]] )

Parameters

$o_object | Object variable of an InternetExplorer.Application, Window or Frame object
$s_linkText | Text displayed on the web page for the desired link to click
$i_index | Optional: If the link text occurs more than once, specify which instance you want by 0-based index
$f_wait | Optional: specifies whether to wait for page to load before returning 0 = Return immediately, not waiting for page to load 1 = (Default) Wait for page load to complete before returning

Return Value

Success: | Returns -1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 1 ($_IEStatus_GeneralError) = General Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
 | 6 ($_IEStatus_LoadWaitTimeout) = Load Wait Timeout
 | 7 ($_IEStatus_NoMatch) = No Match
 | 8 ($_IEStatus_AccessIsDenied) = Access Is Denied
 | 9 ($_IEStatus_ClientDisconnected) = Client Disconnected
@Extended: | Contains invalid parameter number

Remarks

Not all elements that appear to be links actually are. It is common practice to attach onClick JavaScript events to other DOM elements to simulate the behavior of links. To activate such elements, use "click" with _IEAction.

Related

_IELinkClickByIndex, _IELoadWait

Example

; *******************************************************
; Example 1 - Open browser with basic example, click on the link
; with text "user forum"
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("basic")
_IELinkClickByText ($oIE, "user forum")

; *******************************************************
; Example 2 - Open browser to the AutoIt homepage, loop through the links
; on the page and click on the link with text "wallpaper"
; using a sub-string match.
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate("http://www.autoitscript.com")

$sMyString = "wallpaper"
$oLinks = _IELinkGetCollection($oIE)
For $oLink in $oLinks
$sLinkText = _IEPropertyGet($oLink, "innerText")
If StringInStr($sLinkText, $sMyString) Then
_IEAction($oLink, "click")
ExitLoop
EndIf
Next


Function _IELinkGetCollection

Function Reference

_IELinkGetCollection

Returns a collection object containing all links in the document or a single link by index.

#include <IE.au3>
_IELinkGetCollection ( ByRef $o_object [, $i_index = -1] )

Parameters

$o_object | Object variable of an InternetExplorer.Application, Window or Frame object
$i_index | Optional: specifies whether to return a collection or indexed instance 0 or positive integer returns an indexed instance -1 = (Default) returns a collection

Return Value

Success: | Returns an object collection of all links in the document, @EXTENDED = link count
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 5 ($_IEStatus_InvalidValue) = Invalid Value
 | 7 ($_IEStatus_NoMatch) = No Match
@Extended: | Contains invalid parameter number

Remarks

Not all elements that appear to be links actually are. It is common practice to attach onClick JavaScript events to other DOM elements to simulate the behavior of links. To activate such elements, use "click" with _IEAction.

Related

None.

Example

; *******************************************************
; Example 1 - Open browser with basic example, get link collection,
; loop through items and display the associated link URL references
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("basic")
$oLinks = _IELinkGetCollection ($oIE)
$iNumLinks = @extended
MsgBox(0, "Link Info", $iNumLinks & " links found")
For $oLink In $oLinks
MsgBox(0, "Link Info", $oLink.href)
Next


Function _IELoadWait

Function Reference

_IELoadWait

Wait for a browser page load to complete before returning.

#include <IE.au3>
_IELoadWait ( ByRef $o_object [, $i_delay = 0 [, $i_timeout = -1]] )

Parameters

$o_object | Object variable of an InternetExplorer.Application or DOM element
$i_delay | Optional: Milliseconds to wait before checking status
$i_timeout | Optional: Period of time to wait before exiting function (default = 300000 ms aka 5 min)

Return Value

Success: | Returns 1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 1 ($_IEStatus_GeneralError) = General Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
 | 6 ($_IEStatus_LoadWaitTimeout) = Load Wait Timeout
 | 8 ($_IEStatus_AccessIsDenied) = Access Is Denied
 | 9 ($_IEStatus_ClientDisconnected) = Client Disconnected
@Extended: | Contains invalid parameter number

Remarks

Several IE.au3 functions call _IELoadWait() automatically (e.g. _IECreate(), _IENavigate() etc.). Most functions that do this also allow you to turn this off with a $f_wait parameter if you do not want the wait or if you want to call it yourself.

When document objects or DOM elements are passed to _IELoadWait, it will check the readyState of the container elements up to and including the parentWindow.

Browser scripting security restrictions may sometimes prevent _IELoadWait from guaranteeing that a page is fully loaded and can occasionally result in untrapped errors. In these cases you may need to avoid calling _IELoadWait and attempt to employ other methods of insuring that the page load has completed. These methods might include using a Sleep command, examining browser status bar text and other methods. When using functions that call _IELoadWait for objects other than the InternetExplorer (browser) object, you may also be successful by calling _IELoadWait for the browser yourself (e.g. _IELoadWait($oIE)).

The most common causes of trouble are page redirects and cross-site scripting security restrictions associated with frames. Page re-writing techniques employed by some applications (e.g. Gmail) can also cause trouble here.

Related

_IELoadWaitTimeout, _IECreate, _IENavigate, _IEFormSubmit, _IELinkClickByText, _IELinkClickByIndex, _IEImgClick, _IEFormImageClick, _IEBodyWriteHTML, _IEDocWriteHTML, _IEAction

Example

; *******************************************************
; Example 1 - Open the AutoIt forum page, tab to the "View new posts"
; link and activate the link with the enter key.
; Then wait for the page load to complete before moving on.
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("http://www.autoitscript.com/forum/index.php")
Send("{TAB 12}")
Send("{ENTER}")
_IELoadWait ($oIE)


Function _IELoadWaitTimeout

Function Reference

_IELoadWaitTimeout

Retrieve or set the current value in milliseconds _IELoadWait will try before timing out.

#include <IE.au3>
_IELoadWaitTimeout ( [$i_timeout = -1] )

Parameters

$i_timeout Optional: retrieve or specify the number of milliseconds
0 or positive integer sets timeout to this value
-1 = (Default) returns the current timeout value (stored in global variable $__IELoadWaitTimeout)

Return Value

Success: | If $i_timeout = -1, returns the current timeout value, else returns 1
Failure: | None

Remarks

There is no way to completely disable the Timeout value. You can functionally do this however by setting it to a very large positive integer. The initial timeout value is 30000 ms (5 minutes).

Related

_IELoadWait

Example

; *******************************************************
; Example 1 - Obtain current timeout value
; *******************************************************
;
#include <IE.au3>
$iCurrentTimeout = _IELoadWaitTimeout ()

; *******************************************************
; Example 2 - Set timeout to 1 minute (60000 milliseconds)
; *******************************************************
;
#include <IE.au3>
_IELoadWaitTimeout (60000)


Function _IENavigate

Function Reference

_IENavigate

Directs an existing browser window to navigate to the specified URL.

#include <IE.au3>
_IENavigate ( ByRef $o_object, $s_url [, $f_wait = 1] )

Parameters

$o_object | Object variable of an InternetExplorer.Application, Window or Frame object
$s_url | URL to navigate to (e.g. "http://www.autoitscript.com")
$f_wait | Optional: specifies whether to wait for page to load before returning 0 = Return immediately, not waiting for page to load 1 = (Default) Wait for page load to complete before returning

Return Value

Success: | Returns -1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 1 ($_IEStatus_GeneralError) = General Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
 | 6 ($_IEStatus_LoadWaitTimeout) = Load Wait Timeout
 | 8 ($_IEStatus_AccessIsDenied) = Access Is Denied
 | 9 ($_IEStatus_ClientDisconnected) = Client Disconnected
@Extended: | Contains invalid parameter number

Remarks

This function always returns a value of -1. This is because the navigate method has no return value and therefore nothing can be implied from it. You will need to employ other methods to determine success or failure of the navigation.

Related

_IECreate, _IECreateEmbedded

Example

; *******************************************************
; Example 1 - Create a browser window and navigate to a website,
; wait 5 seconds and navigate to another
; wait 5 seconds and navigate to another
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("www.autoitscript.com")
Sleep(5000)
_IENavigate ($oIE, "http://www.autoitscript.com/forum/index.php?")
Sleep(5000)
_IENavigate ($oIE, "http://www.autoitscript.com/forum/index.php?showforum=9")

; *******************************************************
; Example 2 - Create a browser window and navigate to a website,
; do not wait for page load to complete before moving to next line
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("www.autoitscript.com", 0)
MsgBox(0, "_IENavigate()", "This code executes immediately")


Function _IEPropertyGet

Function Reference

_IEPropertyGet

Returns a select property of the Browser or DOM element.

#include <IE.au3>
_IEPropertyGet ( ByRef $o_object, $s_property )

Parameters

$o_object | Object variable of an InternetExplorer.Application or DOM element
$s_property | Property selection (see remarks)

Return Value

Success: | Value of selected Property
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
 | 5 ($_IEStatus_InvalidValue) = Invalid Value
@Extended: | Contains invalid parameter number

Remarks

Further information can be found at MSDN.

The following tables provide a description of each property available for use. Some properties to DOM elements, others to the browser.

Browser Properties

Property | Description
"addressbar" | Retrieves a Boolean value indicating whether the browser address bar is visible or hidden.
"browserx" | Retrieves the x-coordinate of the top left corner of a document element, relative to the browser.
"browsery" | Retrieves the y-coordinate of the top left corner of a document element, relative to the browser.
"screenx" | Retrieves the x-coordinate of the top left corner of a document element or the browser, relative to the screen.
"screeny" | Retrieves the y-coordinate of the top left corner of a document element or the browser, relative to the screen.
"busy" | Retrieves a Boolean value indicating whether the object is engaged in a navigation or downloading operation.
"contenteditable" | Retrieves a Boolean value that indicates whether the object can be edited with mouse and keyboard.
"fullscreen" | Retrieves a Boolean value that indicates whether the browser is in full-screen or normal window mode.
"height" | Retrieves the height of the browser main window or a document element.
"hwnd" | Retrieves the handle of the Internet Explorer main window. Can be used in most AutoIt Win* functions.
"innerhtml" | Retrieves the rendered HTML of an element excluding the beginning and ending element tags.
"innertext" | Retrieves the rendered Text (but not any tags) of an element. Typically identical to outertext.
"isdisabled" | Retrieves the value indicating whether the user can interact with the object.
"left" | Retrieves the screen coordinate of the left edge of the main window of the object.
"locationname" | Retrieves the name of the resource that Internet Explorer is currently displaying.
"locationurl" | Retrieves the URL of the resource that Internet Explorer is currently displaying.
"menubar" | Retrieves a Boolean value that indicates whether the browser menu bar is visible.
"offline" | Retrieves a Boolean value that indicates whether the browser is currently operating in offline mode.
"outertext" | Retrieves the rendered Text (but not any tags) of an element. Typically identical to innertext.
"outerhtml" | Retrieves the rendered HTML of an element including the beginning and ending element tags.
"readystate" | Retrieves the ready state of the object.
"referrer" | Retrieves a string of the URL of the page from which the current page was accessed (but only if accessed via a link on that page, else the string is null).
"resizable" | Retrieves a value that indicates whether the object can be resized.
"screenx" | Retrieves the x-coordinate of the top left corner of a document object or the browser, relative to the screen.
"screeny" | Retrieves the y-coordinate of the top left corner of a document object or the browser, relative to the screen.
"silent" | Retrieves a value that indicates whether the browser can show dialog boxes.
"statusbar" | Retrieves a value that indicates whether the status bar for the object is visible.
"statustext" | Retrieves the text in the status bar for the object.
"theatermode" | Retrieves a Boolean value indicating whether the browser is in Theater Mode. In theater mode, the browser main window fills the entire screen and displays a toolbar with a minimal set of navigational buttons.
"title" | Retrieves the document title. Note that this is different than the window title which typically starts with the document title, but has additional text specified in the windows registry appended to it.
"toolbar" | Retrieves a Boolean value indicating whether the tool bar of the browser is visible or hidden.
"top" | Retrieves the screen coordinate of the top edge of the main window of the object.
"visible" | Retrieves a value that indicates whether the object is visible or hidden.
"width" | Retrieves the width of the browser main window or a document element.

ClientInfo Properties

Property | Description
"appcodename" | Retrieves the code name of the browser (the property has a default value of Mozilla).
"appminorversion" | Retrieves the application's minor version value.
"appname" | Retrieves the name of the browser (the property has a default value of Microsoft Internet Explorer).
"appversion" | Retrieves the platform and version of the browser.
"browserlanguage" | Retrieves the current browser language (the value will be one of these Language Codes).
"cookieenabled" | Retrieves whether client-side persistent cookies are enabled in the browser. Persistent cookies are those that are stored on the client-side computer.
"cpuclass" | Retrieves a string denoting the CPU class (the return values can be found here).
"javaenabled" | Returns whether Java is enabled.
"online" | Retrieves a value indicating whether the system is in global offline mode.
"platform" | Retrieves the name of the user's operating system (the return values can be found here).
"systemlanguage" | Retrieves the default language used by the operating system (the value will be one of these Language Codes).
"useragent" | Retrieves a string equivalent to the HTTP user-agent request header.
"userlanguage" | Retrieves the operating system's natural language setting (the value will be one of these Language Codes).
"vcard" | Returns an array containing each attribute in the userProfile object (a list of attributes can be found here). The return is a two dimentional array, where the first dimention has two elements. The first element (0) contains the attribute names, the second element (1) contains the corresponding values. The second dimention has 29 elements (0 to 28).

Related

_IEPropertySet

Example

; *******************************************************
; Example 1 - Open a browser with the basic example, check to see if the
; addressbar is visible, if it is turn it off, if it is not turn it on
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("basic")
If _IEPropertyGet ($oIE, "addressbar") Then
MsgBox(0, "AddressBar Status", "AddressBar Visible, turning it off")
_IEPropertySet ($oIE, "addressbar", False)
Else
MsgBox(0, "AddressBar Status", "AddressBar Invisible, turning it on")
_IEPropertySet ($oIE, "addressbar", True)
EndIf

; *******************************************************
; Example 2 - Open a browser with the form example and get a reference to the form
; textarea element. Get the coordinates and dimensions of the text area,
; outline its shape with the mouse and come to rest in the center
; *******************************************************
;
$oIE = _IE_Example("form")

$oForm = _IEFormGetObjByName($oIE, "ExampleForm")
$oTextArea = _IEFormElementGetObjByName($oForm, "textareaExample")

; Get coordinates and dimensions of the textarea
$iScreenX = _IEPropertyGet($oTextArea, "screenx")
$iScreenY = _IEPropertyGet($oTextArea, "screeny")
$iBrowserX = _IEPropertyGet($oTextArea, "browserx")
$iBrowserY = _IEPropertyGet($oTextArea, "browserY")
$iWidth = _IEPropertyGet($oTextArea, "width")
$iHeight = _IEPropertyGet($oTextArea, "height")

; Outline the textarea with the mouse, come to rest in the center
MouseMove($iScreenX, $iScreenY)
MouseMove($iScreenX + $iWidth, $iScreenY)
MouseMove($iScreenX + $iWidth, $iScreenY + $iHeight)
MouseMove($iScreenX, $iScreenY + $iHeight)
MouseMove($iScreenX, $iScreenY)
MouseMove($iScreenX + $iWidth/2, $iScreenY + $iHeight/2)


Function _IEPropertySet

Function Reference

_IEPropertySet

Set a select property of the Browser or DOM element.

#include <IE.au3>
_IEPropertySet ( ByRef $o_object, $s_property, $newvalue )

Parameters

$o_object | Object variable of an InternetExplorer.Application
$s_property | Property selection (see remarks)
$newvalue | The new value to be set into the Browser Property

Return Value

Success: | Returns 1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
 | 5 ($_IEStatus_InvalidValue) = Invalid Value
@Extended: | Contains invalid parameter number

Remarks

Further information can be found at MSDN.

The following table provide a description of each property available for use. Some properties to DOM elements, others to the browser.

Browser Properties

Property | Description
"addressbar" | Specifies whether the address bar of the object is visible or hidden.
"contenteditable" | Specifies a Boolean value that indicates whether the object can be edited with mouse and keyboard.
"height" | Specifies the height of the browser main window.
"innerhtml" | Sets the rendered HTML of an element excluding the beginning and ending element tags.
"innertext" | Sets the rendered Text (but not any tags) of an element. Typically identical to outertext.
"left" | Specifies the screen coordinate of the left edge of the browser main window.
"menubar" | Specifies a Boolean value that indicates whether the browser menu bar is visible.
"offline" | Specifies a Boolean value that indicates whether the browser is currently operating in offline mode.
"outertext" | Sets the rendered Text (but not any tags) of an element. Typically identical to innertext.
"outerhtml" | Sets the rendered HTML of an element including the beginning and ending element tags.
"resizable" | Specifies a Boolean value that indicates whether the object can be resized.
"silent" | Specifies a Boolean value that indicates whether the browser can show dialog boxes.
"statusbar" | Specifies a value that indicates whether the browser status bar is visible.
"statustext" | Specifies the text in the browser status bar.
"theatermode" | Specifies a Boolean value indicating whether the browser is in Theater Mode. In theater mode, the browser main window fills the entire screen and displays a toolbar with a minimal set of navigational buttons.
"title" | Sets the document title. Note that this is different than the window title which typically starts with the document title, but has additional text specified in the windows registry appended to it.
"toolbar" | Specifies a Boolean value indicating whether the tool bar of the browser is visible or hidden.
"top" | Specifies the screen coordinate of the top edge of the browser main window.
"width" | Specifies the width of the browser main window.

Related

_IEPropertyGet

Example

; *******************************************************
; Example 1 - Open a browser with the basic example, check to see if the
; addressbar is visible, if it is not turn it on. Then change
; the text displayed in the statusbar
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("basic")
If Not _IEPropertyGet ($oIE, "statusbar") Then _IEPropertySet ($oIE, "statusbar", True)
_IEPropertySet ($oIE, "statustext", "Look What I can Do")
Sleep(1000)
_IEPropertySet ($oIE, "statustext", "I can change the status text")


Function _IEQuit

Function Reference

_IEQuit

Close the browser and remove the object reference to it.

#include <IE.au3>
_IEQuit ( ByRef $o_object )

Parameters

$o_object Object variable of an InternetExplorer.Application

Return Value

Success: | Returns 1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
@Extended: | Contains invalid parameter number

Remarks

_IEQuit is particularly important when creating or working with invisible instances of Internet Explorer. When AutoIt exits when working with visible instances of a browser, the browser continues to run and the visible window is left for the user to manage. When the browser instance is invisible however, when AutoIt exits the browser process is left running and there is no user interface to interact with and an orphan Iexplore.exe process is left running on the system. It is therefore good practice to call _IEQuit whenever the browser process is not needed after the script exists.

_IEQuit is not allowed with embedded browser objects created with _IECreateEmbedded. The browser processes associated with those objects will close when their parent GUI window is destroyed.

Related

_IEAttach, _IECreate

Example

; *******************************************************
; Example 1 - Create an invisible browser window, navigate to a
; website, retrieve some information and Quit
; *******************************************************
;
#include <IE.au3>
$oIE = _IECreate ("http://sourceforge.net", 0, 0)
; Display the innerText on an element on the page with a name of "sfmarquee"
$oMarquee = _IEGetObjByName ($oIE, "sfmarquee")
MsgBox(0, "SourceForge Information", $oMarquee.innerText)
_IEQuit ($oIE)


Function _IETableGetCollection

Function Reference

_IETableGetCollection

Returns a collection object variable representing all the tables in a document or a single table by index.

#include <IE.au3>
_IETableGetCollection ( ByRef $o_object [, $i_index = -1] )

Parameters

$o_object | Object variable of an InternetExplorer.Application, Window or Frame object
$i_index | Optional: specifies whether to return a collection or indexed instance 0 or positive integer returns an indexed instance -1 = (Default) returns a collection

Return Value

Success: | Returns an object collection of all tables in the document, @EXTENDED = table count
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 5 ($_IEStatus_InvalidValue) = Invalid Value
 | 7 ($_IEStatus_NoMatch) = No Match
@Extended: | Contains invalid parameter number

Remarks

None.

Related

None.

Example

; *******************************************************
; Example 1 - Open a browser with the table example, get a reference to the first table
; on the page (index 0) and read its contents into a 2-D array
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("table")
$oTable = _IETableGetCollection ($oIE, 0)
$aTableData = _IETableWriteToArray ($oTable)

; *******************************************************
; Example 2 - Open a browser with the table example, get a reference to the
; table collection and display the number of tables on the page
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("table")
$oTable = _IETableGetCollection ($oIE)
$iNumTables = @extended
MsgBox(0, "Table Info", "There are " & $iNumTables & " tables on the page")


Function _IETableWriteToArray

Function Reference

_IETableWriteToArray

Reads the contents of a Table into an array.

#include <IE.au3>
_IETableWriteToArray ( ByRef $o_object [, $f_transpose] )

Parameters

$o_object | Object variable of an InternetExplorer.Application, Table object
$f_transpose | Boolean value specifying whether to swap the rows and columns in the output array

Return Value

Success: | Returns a 2-dimensional array containing the contents of the Table
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
@Extended: | Contains invalid parameter number

Remarks

When table cells span multiple columns or rows, blank array elements are added to properly align the results. Data in spanning cells will be in the left or uppermost array elements.

Tables are often nested in HTML documents. If all of your data is unexpectedly returned in a single array element, you may need to reference a more deeply nested table to this function.

Related

_IETableGetCollection

Example

; *******************************************************
; Example 1 - Open a browser with the table example, get a reference to the second table
; on the page (index 1) and read its contents into a 2-D array
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("table")
$oTable = _IETableGetCollection ($oIE, 1)
$aTableData = _IETableWriteToArray ($oTable)

; *******************************************************
; Example 2 - Same as Example 1, except transpose the output array and display
; the results with _ArrayDisplay()
; *******************************************************
;
#include <IE.au3>
#include <Array.au3>
$oIE = _IE_Example ("table")
$oTable = _IETableGetCollection ($oIE, 1)
$aTableData = _IETableWriteToArray ($oTable, True)
_ArrayDisplay($aTableData)


Function _IETagNameAllGetCollection

Function Reference

_IETagNameAllGetCollection

Returns a collection object all elements in the document or document hierarchy in source order or a single element by index.

#include <IE.au3>
_IETagNameAllGetCollection ( ByRef $o_object [, $i_index = -1] )

Parameters

$o_object | Object variable of an InternetExplorer.Application, Window, Frame, iFrame or any object in the DOM
$i_index | Optional: specifies whether to return a collection or indexed instance 0 or positive integer returns an indexed instance -1 = (Default) returns a collection

Return Value

Success: | Returns an object variable containing the Tag collection, @EXTENDED = Tag count
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
 | 5 ($_IEStatus_InvalidValue) = Invalid Value
 | 7 ($_IEStatus_NoMatch) = No Match
@Extended: | Contains invalid parameter number

Remarks

The DOM is hierarchical, so if the object passed is the document object, all elements in the document are returned. If the object passed in is an object inside the document (e.g. a TABLE object), then only the elements inside that object are returned.

Related

_IETagNameGetCollection

Example

; *******************************************************
; Example 1 - Open a browser with the basic example, get the collection
; of all elements and display the tagname and innerText of each
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("basic")
$oElements = _IETagNameAllGetCollection ($oIE)
For $oElement In $oElements
MsgBox(0, "Element Info", "Tagname: " & $oElement.tagname & @CR & "innerText: " & $oElement.innerText)
Next


Function _IETagNameGetCollection

Function Reference

_IETagNameGetCollection

Returns a collection object of all elements in the object with the specified TagName or a single element by index.

#include <IE.au3>
_IETagNameGetCollection ( ByRef $o_object, $s_TagName [, $i_index = -1] )

Parameters

$o_object | Object variable of an InternetExplorer.Application, Window, Frame, iFrame or any object in the DOM
$s_TagName | TagName of collection to return (e.g. IMG, TR etc.)
$i_index | Optional: specifies whether to return a collection or indexed instance 0 or positive integer returns an indexed instance -1 = (Default) returns a collection

Return Value

Success: | Returns an object variable containing the specified Tag collection, @EXTENDED = specified Tag count
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_IEStatus_Success) = No Error
 | 3 ($_IEStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_IEStatus_InvalidObjectType) = Invalid Object Type
 | 5 ($_IEStatus_InvalidValue) = Invalid Value
 | 7 ($_IEStatus_NoMatch) = No Match
@Extended: | Contains invalid parameter number

Remarks

The DOM is hierarchical, so if the object passed is the document object, the specified elements in the document are returned. If the object passed is an object inside the document (e.g. a TABLE object), then only the specified elements inside that object are returned.

Related

_IETagNameAllGetCollection

Example

; *******************************************************
; Example 1 - Open a browser with the form example, get the collection
; of all INPUT tags and display the formname and type of each
; *******************************************************
;
#include <IE.au3>
$oIE = _IE_Example ("form")
$oInputs = _IETagNameGetCollection ($oIE, "input")
For $oInput In $oInputs
MsgBox(0, "Form Input Type", "Form: " & $oInput.form.name & " Type: " & $oInput.type)
Next


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: Inet Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_GetIP | Get public IP address of a network/computer.
_INetExplorerCapable | Converts a string to IE(Internet Explorer) capable line
_INetGetSource | Gets the source from an URL without writing a temp file.
_INetMail | Opens default user's mail client with given address, subject, and body.
_INetSmtpMail | Sends an email without using an external email program.
_TCPIpToName | Resolves IP adress to Hostname(s)


Function _GetIP

Function Reference

_GetIP

Get public IP address of a network/computer.

#include <INet.au3>
_GetIP ( )

Parameters

None

Return Value

Success: | Returns the public IP Address
Failure: | Returns -1 and sets @ERROR = 1

Remarks

This only returns the Public IP address of a computer or network (i.e. the public IP on the WAN link of your NAT router). The address is determined by accessing an external IP discovery web site like checkip.dyndns.org or www.whatismyip.com.

Related

None.

Example

#include <Inet.au3>
$PublicIP = _GetIP()
MsgBox(0, "IP Address", "Your IP Address is: " & $PublicIP)


Function _INetExplorerCapable

Function Reference

_INetExplorerCapable

Converts a string to IE(Internet Explorer) capable line

#include <INet.au3>
_INetExplorerCapable ( $s_IEString )

Parameters

$s_IEString String to be converted

Return Value

Success: | Converted string
Failure: | Blank string and @error = 1

Remarks

This converts IE uncapable characters to '%' and their hex value

Related

None.

Example

#include <INet.au3>

MsgBox(0, "", _INetExplorerCapable(InputBox("", "Enter a string to convert into browser readable text")))


Function _INetGetSource

Function Reference

_INetGetSource

Gets the source from an URL without writing a temp file.

#include <INet.au3>
_INetGetSource ( $s_URL )

Parameters

$s_URL (The URL of the site.) eg 'www.autoitscript.com'

Return Value

Success: | Returns the source code.
Failure: | 0 and sets @ERROR = 1

Remarks

None.

Related

INetGet

Example

#include <INet.au3>
ConsoleWrite(_INetGetSource('www.autoitscript.com'))


Function _INetMail

Function Reference

_INetMail

Opens default user's mail client with given address, subject, and body.

#include <INet.au3>
_INetMail ( $s_MailTo, $s_MailSubject, $s_MailBody )

Parameters

$s_MailTo | Address for the E-Mail
$s_MailSubject | Subject for the E-Mail
$s_MailBody | Body for the E-Mail

Return Value

Success: | Process identifier for the E-Mail client
Failure: | See remarks.

Remarks

If this fails to find the correct mail client the script will depend on the status of Opt('RunErrorsFatal', *)
Failure and Opt('RunErrorsFatal',1) will crash script
Failure and Opt('RunErrorsFatal',0) will return blank string and @error = 1

It is recomended before using this function to set Opt('RunErrorsFatal', 0)!

Related

None.

Example

#include <INet.au3>

$Address = InputBox('Address', 'Enter the E-Mail address to send message to')
$Subject = InputBox('Subject', 'Enter a subject for the E-Mail')
$Body = InputBox('Body', 'Enter the body (message) of the E-Mail')
MsgBox(0,'E-Mail has been opened','The E-Mail has been opened and process identifier for the E-Mail client is ' & _INetMail($address, $subject, $body))


Function _INetSmtpMail

Function Reference

_INetSmtpMail

Sends an email without using an external email program.

#include <INet.au3>
_INetSmtpMail ( $s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress [,$s_Subject [,$as_Body [,$s_helo, [,$s_first [,$b_trace]]]]])

Parameters

$s_SmtpServer | Smtp server the eMail is to be sent though May be either alpha or a numeric IP address. In order to fight spam, many ISPs require this to be their server. eg "smtp.ispdomain.com", "mail.ispdomain.com" or "192.168.1.1"
$s_FromName | The name you wish the message to appear to be sent from. eg "Bob Smith"
$s_FromAddress | The email address you wish the message to appear to be sent from. eg "bob.smith@mydomain.com".
$s_ToAddress | The email address the message is to go to. eg "jane.brown@yourdomain.com"
$s_Subject | [optional] The subject of the email.
$as_Body | [optional] The body of the email as a single dimensional array of strings. Each value in the array will be terminated with a @CRLF in the email.
$s_helo | [optional] identifier for the smtp server connection (by default @ComputerName). If Smtp server require a "EHLO" string just set the string to "EHLO " & @ComputerName.
$s_first | [optional] string sent before helo for the smtp server connection (by default {SPACE}). To not send any character this parameter must equal -1, some SMTP server required it.
$b_trace | [optional] trace the dialog in a splash window

Return Value

On Success - Returns 1
On Failure - Returns 0 and sets:
@ERROR = 1 - Invalid Parameters
@ERROR = 2 - Unable to start TCP
@ERROR = 3 - Unable to resolve IP
@ERROR = 4 - Unable to create socket
@ERROR = 5x - Cannot open SMTP session. x indicates the index number of last command issued to the SMTP server.
@ERROR = 50x - Cannot send body. x indicates the line number of $as_Body (first line is 0).
@ERROR = 5000 - Cannot close SMTP session

Remarks

This function sends a email directly through an SMTP server without the use of a third party email client. Requires AutoIt3 v 3.1.1.97 or better.

Related

_INetMail

Example

#include <INet.au3>

$s_SmtpServer = "mysmtpserver.com.au"
$s_FromName = "My Name"
$s_FromAddress = "From eMail Address"
$s_ToAddress = "To eMail Address"
$s_Subject = "My Test UDF"
Dim $as_Body[2]
$as_Body[0] = "Testing the new email udf"
$as_Body[1] = "Second Line"
$Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body)
$err = @error
If $Response = 1 Then
MsgBox(0, "Success!", "Mail sent")
Else
MsgBox(0, "Error!", "Mail failed with error code " & $err)
EndIf


Function _TCPIpToName

Function Reference

_TCPIpToName

Resolves IP adress to Hostname(s)

#include <iNet.au3>
_TCPIpToName ( $sIp [,$iOption = 0 [, $hDll_Ws2_32 = "Ws2_32.dll" ]] )

Parameters

$sIp | Ip Adress in dotted (v4) Format
$iOption | Optional, Default = 0 0 = Return String Hostname 1 = Return Array (see Remarks)
$hDll_Ws2_32 | Optional, Handle to Ws2_32.dll

Return Value

Success: | Hostname or Array (see Remarks)
Failure: | ""
@Error: | 0 = No error.
 | 1 = inet_addr DllCall Failed
 | 2 = inet_addr Failed
 | 3 = gethostbyaddr DllCall Failed
 | 4 = gethostbyaddr Failed, WSAGetLastError = @Extended
 | 5 = gethostbyaddr Failed, WSAGetLastError Failed
 | 6 = strlen/sZStringRead Failed
 | 7 = Error reading Aliases Array

Remarks

A successfull WSAStartup (Done by TCPStartup) is required.
if $iOption = 1 then the returned Array looks Like this:
$aResult[0] = Number of elemets
$aResult[1] = "Hostname"
$aResult[2] = "Alias 1"
$aResult[3] = "Alias 2"
...

Related

TCPStartup, TCPNameToIP

Example

; Example 1
#include <inet.au3>
Dim $sResult, $sIp
TCPStartup()
$sIp = TCPNameToIP("hiddensoft.com")
$sResult = _TCPIpToName ($sIp)
If @error Then
MsgBox(0, "_TCPIpToName()", "@error = " & @error & @LF & "@extended = " & @extended)
Else
MsgBox(0, "hiddensoft.com realy is:", $sResult)
EndIf

; Example 2
#include <array.au3>
#include <inet.au3>
Dim $aResult, $sIp
TCPStartup()
$sIp = _GetIP()
$aResult = _TCPIpToName ($sIp, 1)
If @error Then
MsgBox(0, "_TCPIpToName()", "@error = " & @error & @LF & "@extended = " & @extended)
Else
_ArrayDisplay($aResult, "Local Hostname(s)")
EndIf


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: Math Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_Degree | Converts radians to degrees.
_MathCheckDiv | Checks if NumA is divisable by NumB
_Max | Evaluates which of the two numbers is higher.
_Min | Evaluates which of the two numbers is lower.
_Radian | Converts degrees to radians.


Function _Degree

Function Reference

_Degree

Converts radians to degrees.

#include <Math.au3>
_Degree ( $nRadians )

Parameters

$nRadians Radians to be converted into degrees.

Return Value

Success: | Degrees converted from radians.
Failure: | Blank string and @error set to 1.

Remarks

Can be used in conjunction with the Sin(), Cos(), and Tan() functions.

Related

_Radian, Sin, Cos, Tan, ASin, ACos, ATan

Example

#include <Math.au3>

$radians = 3.14159265358979
$degrees = _Degree($radians)

MsgBox(0, "Radians to Degrees", $radians & " radians = " & $degrees & " degrees")


Function _MathCheckDiv

Function Reference

_MathCheckDiv

Checks if NumA is divisable by NumB

#include <Math.au3>
_MathCheckDiv ( $i_NumA, $i_NumB )

Parameters

$i_NumA | Number to check
$i_NumB | Number to divide by

Return Value

Success: | Returns 1 for not divisable,
 | 2 for divisable.
Failure: | Returns -1 and @error = 1 if not valid numbers.

Remarks

This function will also enable checking if a number is even/odd by making the second parameter = 2

Related

None.

Example

#include <math.au3>
$I_Var = InputBox('Odd or Even', 'Enter a number:')
$I_Result = _MathCheckDiv($I_Var, 2)
If $I_Result = -1 Or @error = 1 Then
MsgBox(0,'','You did not enter a valid number')
ElseIf $I_Result = 1 Then
MsgBox(0,'','Number is odd')
ElseIf $I_Result = 2 Then
MsgBox(0,'','Number is even')
Else
MsgBox(0,'','Could not parse $I_Result')
EndIf


Function _Max

Function Reference

_Max

Evaluates which of the two numbers is higher.

#include <Math.au3>
_Max ( $nNum1, $nNum2 )

Parameters

$nNum1 | First number.
$nNum2 | Second number.

Return Value

Success: | Returns the higher of the two numbers.
Failure: | Returns 0.
@Error: | 0 = No error.
 | 1 = $nNum1 isn't a number.
 | 2 = $nNum2 isn't a number.

Remarks

This function works with floats as well as integers.

Related

_Min

Example

#include <Math.au3>

$x = _Max(25, 10) ; returns 25


Function _Min

Function Reference

_Min

Evaluates which of the two numbers is lower.

#include <Math.au3>
_Min ( $nNum1, $nNum2 )

Parameters

$nNum1 | First number.
$nNum2 | Second number.

Return Value

Success: | Returns the lower of the two numbers.
Failure: | Returns 0.
@Error: | 0 = No error.
 | 1 = $nNum1 isn't a number.
 | 2 = $nNum2 isn't a number.

Remarks

This function works with floats as well as integers.

Related

_Max

Example

#include <Math.au3>

$x = _Min(25, 10) ; returns 10


Function _Radian

Function Reference

_Radian

Converts degrees to radians.

#include <Math.au3>
_Radian ( $nDegrees )

Parameters

$aDegrees Degrees to be converted into radians.

Return Value

Success: | Radians converted from degrees.
Failure: | Blank string and @error set to 1

Remarks

Can be used in conjunction with the Sin(), Cos(), and Tan() functions.

Related

_Degree, Sin, Cos, Tan, ASin, ACos, ATan

Example

#include <Math.au3>

$degrees = 35
$radians = _Radian($degrees)

MsgBox(0, "Degrees to Radians", $degrees & " degrees = " & $radians & " radians")


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: Misc Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_ChooseColor | Creates a Color dialog box that enables the user to select a color.
_ChooseFont | Creates a Font dialog box that enables the user to choose attributes for a logical font.
_ClipPutFile | Copy Files to Clipboard Like Explorer does
_Iif | Perform a boolean test within an expression.
_IsClassName | Check ClassName of the control.
_IsPressed | Check if key has been pressed
_MouseTrap | Confine the Mouse Cursor to specified coords.
_SendMessage | Wrapper for commonly used Dll Call
_Singleton | Check if no other occurrence is running.


Function _ChooseColor

Function Reference

_ChooseColor

Creates a Color dialog box that enables the user to select a color.

#include <Misc.au3>
_ChooseColor([$i_ReturnType = 0[, $i_colorref = 0[, $i_refType=0[, $h_wnd_owner]]]])

Parameters

$i_ReturnType | Optional: determines return type
$i_colorref | Optional: default selected Color
$i_refType | Optional: Type of $i_colorref passed in
$h_wnd_owner | Optional: Handle of owner window (Default 0)

Return Value

Returns COLORREF rgbcolor if $i_refType = 0 (default)
Returns Hex RGB value if $i_refType = 1
Returns Hex BGR Color if $i_refType = 2
if error occurs, @error is set

Remarks

$i_ReturnType = 0 then COLORREF rgbcolor is returned (default)
$i_ReturnType = 1 then Hex BGR Color is returned
$i_ReturnType = 2 Hex RGB Color is returned

$i_colorref = 0 (default)

$i_refType = 0 then $i_colorref is COLORREF rgbcolor value (default)
$i_refType = 1 then $i_colorref is BGR hex value
$i_refType = 2 then $i_colorref is RGB hex value

Related

Example

#include <Misc.au3>

Local $color

$color = _ChooseColor (0)
If (@error) Then
MsgBox(0, "", "Error _ChooseColor: " & @error)
Else
MsgBox(0,"_ChooseColor","COLORREF rgbColors: " & $color)
EndIf

$color = _ChooseColor (1)
If (@error) Then
MsgBox(0, "", "Error _ChooseColor: " & @error)
Else
MsgBox(0,"_ChooseColor","Hex BGR Color: " & $color)
EndIf

$color = _ChooseColor (2, 255) ; default color selected using COLORREF rgbcolor
If (@error) Then
MsgBox(0, "", "Error _ChooseColor: " & @error)
Else
MsgBox(0,"_ChooseColor","Hex RGB Color: " & $color)
EndIf

$color = _ChooseColor (2, 0x0000FF, 1) ; default color selected using BGR hex value
If (@error) Then
MsgBox(0, "", "Error _ChooseColor: " & @error)
Else
MsgBox(0,"_ChooseColor","Hex RGB Color: " & $color)
EndIf

$color = _ChooseColor (2, 0xFF0000, 2) ; default color selected using RGB hex value
If (@error) Then
MsgBox(0, "", "Error _ChooseColor: " & @error)
Else
MsgBox(0,"_ChooseColor","Hex RGB Color: " & $color)
EndIf


Function _ChooseFont

Function Reference

_ChooseFont

Creates a Font dialog box that enables the user to choose attributes for a logical font.

#include <Misc.au3>
_ChooseFont([$s_FontName = "Courier New"[, $i_size = 10[, $i_colorref = 0[, $i_FontWeight = 0[, $i_Italic= 0[, $i_Underline = [0, $i_Strikethru = 0[, $h_wnd_owner]]]]]]])

Parameters

$s_FontName | Optional: Default font name
$i_size | Optional: pointsize of font
$i_colorref | Optional: COLORREF rgbColors
$i_weight | Optional: weight of the font (Default 400)
$i_italic | Optional: Default 0
$i_underline | Optional: Default 0
$i_strikeout | Optional: Default 0
$h_wnd_owner | Optional: Handle of owner window (Default 0)

Return Value

Returns Array, $array[0] contains the number of elements
if error occurs, @error is set

Remarks

$array[1] - attributes = BitOr of italic:2, undeline:4, strikeout:8
$array[2] - fontname
$array[3] - font size = point size
$array[4] - font weight = = 0-1000
$array[5] - COLORREF rgbColors
$array[6] - Hex BGR Color
$array[7] - Hex RGB Color

Related

Example

#include <Misc.au3>

Local $a_font

; Example 1
$a_font = _ChooseFont("Arial", 8)
If (@error) Then
MsgBox(0, "", "Error _ChooseFont: " & @error)
Else
MsgBox(0, "", "Font Name: " & $a_font[2] & @LF & "Size: " & $a_font[3] & @LF & "Weight: " & $a_font[4] & @LF & "COLORREF rgbColors: " & $a_font[5] & @LF & "Hex BGR Color: " & $a_font[6] & @LF & "Hex RGB Color: " & $a_font[7])
EndIf

; Example 2
$a_font = _ChooseFont()
If (@error) Then
MsgBox(0, "", "Error _ChooseFont: " & @error)
Exit
Else
MsgBox(0, "", "Font Name: " & $a_font[2] & @LF & "Size: " & $a_font[3] & @LF & "Weight: " & $a_font[4] & @LF & "COLORREF rgbColors: " & $a_font[5] & @LF & "Hex BGR Color: " & $a_font[6] & @LF & "Hex RGB Color: " & $a_font[7])
EndIf

; Example 3
Local $FontName = $a_font[2]
Local $FontSize = $a_font[3]
Local $ColorRef = $a_font[5]
Local $FontWeight = $a_font[4]
Local $Italic = BitAND($a_font[1], 2)
Local $Underline = BitAND($a_font[1], 4)
Local $Strikethru = BitAND($a_font[1], 8)
$a_font = _ChooseFont($FontName, $FontSize, $ColorRef, $FontWeight, $Italic, $Underline, $Strikethru)
If (@error) Then
MsgBox(0, "", "Error _ChooseFont: " & @error)
Else
MsgBox(0, "", "Font Name: " & $a_font[2] & @LF & "Size: " & $a_font[3] & @LF & "Weight: " & $a_font[4] & @LF & "COLORREF rgbColors: " & $a_font[5] & @LF & "Hex BGR Color: " & $a_font[6] & @LF & "Hex RGB Color: " & $a_font[7])
EndIf


Function _ClipPutFile

Function Reference

_ClipPutFile

Copy Files to Clipboard Like Explorer does

#include <Misc.au3>
_ClipPutFile ( $sFile [, $sSeperator ] )

Parameters

$sFile | Full Path to File(s)
$sSeperator | Seperator for multiple Files, Default = '|'

Return Value

Success: | True
Failure: | False
@ERROR: | 1 - Unable to Open Clipboard
 | 2 - Unable to Empty Cipboard
 | 3 - GlobalAlloc Failed
 | 4 - GlobalLock Failed
 | 5 - Unable to Create H_DROP
 | 6 - Unable to Update Clipboard
 | 7 - Unable to Close Clipboard
 | 8 - GlobalUnlock Failed

Remarks

To Retrive a list of Files stored in the Clipboard use ClipGet().

Related

ClipGet, ClipPut

Example

#include "misc.au3"
Local $fTest
$fTest = _ClipPutFile(@ScriptFullPath)
If Not $fTest Then
MsgBox(0,"_ClipPutFile() call Failed","@error = " & @error)
Else
MsgBox(0,"_ClipPutFile()","Content of Clipboard:" & ClipGet())
EndIf


Function _Iif

Function Reference

_Iif

Perform a boolean test within an expression.

#include <Misc.au3>
_Iif ( $f_Test, $v_TrueVal, $v_FalseVal )

Parameters

$f_Test | Boolean test.
$v_TrueVal | Value to return if $f_Test is true.
$v_FalseVal | Value to return if $f_Test is false.

Return Value

One of $v_TrueVal or $v_FalseVal.

Remarks

Note that all parameters are evaluated, even though only one is returned.

Related

None.

Example

#include <Misc.au3>

Dim $i_Count, $i_Index

For $i_Index = 1 To 2
MsgBox(4096, "Count", "This dialog has displayed " & String($i_Index) & _
" time" & _Iif($i_Index > 1, "s", "") & " so far")
Next

Exit


Function _IsClassname

Function Reference

_IsClassname

Check ClassName of the control.

#include <Misc.au3>
_IsClassName($h_hWnd, $s_ClassName)

Parameters

$h_hWnd control ID/Handle

Return Value

Success: | Returns 1
Failure: | Returns 0 and sets @error

Remarks

None.

Related

None.

Example

#include <Misc.au3>
Run("Notepad")
WinWaitActive("[CLASS:Notepad]")
$hWnd = WinGetHandle("[LAST]")
If _IsClassName($hWnd,"Notepad") Then
Msgbox(0,"Classname","Active window is an Notepad classname")
EndIf


Function _IsPressed

Function Reference

_IsPressed

Check if key has been pressed

#Include <Misc.au3>
_IsPressed ( $s_hexKey [, $v_dll = 'user32.dll' ] )

Parameters

$s_hexKey | key to check for
$v_dll | Optional: Handle to dll or default to user32.dll

Return Value

Success: | Returns 1 if true.
Failure: | Returns 0 if false.

Remarks

01 Left mouse button
02 Right mouse button
04 Middle mouse button (three-button mouse)
05 Windows 2000/XP: X1 mouse button
06 Windows 2000/XP: X2 mouse button
08 BACKSPACE key
09 TAB key
0C CLEAR key
0D ENTER key
10 SHIFT key
11 CTRL key
12 ALT key
13 PAUSE key
14 CAPS LOCK key
1B ESC key
20 SPACEBAR
21 PAGE UP key
22 PAGE DOWN key
23 END key
24 HOME key
25 LEFT ARROW key
26 UP ARROW key
27 RIGHT ARROW key
28 DOWN ARROW key
29 SELECT key
2A PRINT key
2B EXECUTE key
2C PRINT SCREEN key
2D INS key
2E DEL key
30 0 key
31 1 key
32 2 key
33 3 key
34 4 key
35 5 key
36 6 key
37 7 key
38 8 key
39 9 key
41 A key
42 B key
43 C key
44 D key
45 E key
46 F key
47 G key
48 H key
49 I key
4A J key
4B K key
4C L key
4D M key
4E N key
4F O key
50 P key
51 Q key
52 R key
53 S key
54 T key
55 U key
56 V key
57 W key
58 X key
59 Y key
5A Z key
5B Left Windows key
5C Right Windows key
60 Numeric keypad 0 key
61 Numeric keypad 1 key
62 Numeric keypad 2 key
63 Numeric keypad 3 key
64 Numeric keypad 4 key
65 Numeric keypad 5 key
66 Numeric keypad 6 key
67 Numeric keypad 7 key
68 Numeric keypad 8 key
69 Numeric keypad 9 key
6A Multiply key
6B Add key
6C Separator key
6D Subtract key
6E Decimal key
6F Divide key
70 F1 key
71 F2 key
72 F3 key
73 F4 key
74 F5 key
75 F6 key
76 F7 key
77 F8 key
78 F9 key
79 F10 key
7A F11 key
7B F12 key
7C-7F F13 key - F16 key
80H-87H F17 key - F24 key
90 NUM LOCK key
91 SCROLL LOCK key
A0 Left SHIFT key
A1 Right SHIFT key
A2 Left CONTROL key
A3 Right CONTROL key
A4 Left MENU key
A5 Right MENU key

Related

None.

Example

#include <Misc.au3>

$dll = DllOpen("user32.dll")

While 1
Sleep ( 250 )
If _IsPressed("23", $dll) Then
MsgBox(0,"_IsPressed", "End Key Pressed")
ExitLoop
EndIf
WEnd
DllClose($dll)


Function _MouseTrap

Function Reference

_MouseTrap

Confine the Mouse Cursor to specified coords.

#include <Misc.au3>
_MouseTrap ( [ $i_left = 0 [, $i_top = 0 [, $i_right = 0 [, $i_bottom = 0 ]]]] )

Parameters

$i_left | Left coord
$i_top | Top coord
$i_right | Right coord
$i_bottom | Bottom coord

Return Value

Success: | Returns a non zero value
Failure: | Returns 0

Remarks

Use _MouseTrap() with no params to release the Mouse Cursor

Setting only $i_left and $i_top sets:
$i_right = $i_left
$i_bottom = $i_top

Related

None.

Example

#include <GuiConstants.au3>
#include <Misc.au3>

Opt ("MustDeclareVars", 1)

Dim $GUI, $coords[4], $msg

$GUI = GUICreate("Mouse Trap Example", 392, 323)

GUISetState()

While 1
$coords = WinGetPos($GUI)
_MouseTrap ($coords[0], $coords[1], $coords[0] + $coords[2], $coords[1] + $coords[3])
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case Else
;;;
EndSelect
WEnd
_MouseTrap ()
Exit


Function _SendMessage

Function Reference

_SendMessage

Wrapper for commonly used Dll Call

#Include <misc.au3>
_SendMessage ( hWnd, msg [, wParam = 0 [, lParam = 0 [, return = 0 [, wParam Type = "int" [, lParam Type = "int" ]]]]] )

Parameters

hwnd | window/control handle
msg | message to send to control (number)
wParam | Specifies additional message-specific information (Optional: Default 0)
lParam | Specifies additional message-specific information (Optional: Default 0)
return | what to return (Optional: Default 0)
wParam Type | Specifies what type of additional information (Optional: Default "int")
lParam Type | Specifies what type of additional information (Optional: Default "int")

Return Value

return = 0 thru 4 corresponds to the parameter of the _SendMessage Wrapper
return < 0 or > 4 returns array same as DllCall

Remarks

None

Related

DllCall

Example

#include <misc.au3>

_Main()

Func _Main()
Local Const $Off = 2, $On = -1

Opt("WinTitleMatchMode", 4)
$hwnd = WinGetHandle('classname=Progman')
_ToggleMonitor($hWnd, $Off)
Sleep ( 3000 )
_ToggleMonitor($hWnd, $On)
EndFunc

Func _ToggleMonitor($hwnd, $OnOff)
Local Const $WM_SYSCOMMAND = 274
Local Const $SC_MONITORPOWER = 61808
_SendMessage($hWnd, $WM_SYSCOMMAND, $SC_MONITORPOWER, $OnOff)
If @error Then
MsgBox(0,"_ToggleMonitor", "_SendMessage Error: " & @error)
Exit
EndIf
EndFunc


Function _Singleton

Function Reference

_Singleton

Check if no other occurrence is running.

#include <Misc.au3>
_Singleton ( $occurrenceName [,$flag=0 ]] )

Parameters

$occurrenceName | string to identify the occurrence of the script
$flag | when 1 the function return on error

Return Value

On Flag = 1 otherwise the script is exited
Success: | Returns 1
Failure: | Returns 0

Remarks

If an occurrence is already found the script is exited.

The second call to the function in the same running script will fail.

Related

None.

Example

#include "Misc.au3"
if _Singleton("test\test",1) = 0 Then
Msgbox(0,"Warning","An occurence of test is already running")
Exit
EndIf
Msgbox(0,"OK","the first occurence of test is running")


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: Process Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_ProcessGetName | Returns a string containing the process name that belongs to a given PID.
_ProcessGetPriority | Get the priority of an open process
_RunDOS | Executes a DOS command in a hidden command window.


Function _ProcessGetName

Function Reference

_ProcessGetName

Returns a string containing the process name that belongs to a given PID.

#include <Process.au3>
_ProcessGetName ( $iPID )

Parameters

$iPID The PID of a currently running process.

Return Value

Success: | Returns The name of the process.
Failure: | Returns Blank string and sets the @error to the following values:
 | @error = 1 : Process doesn't exist
 | @error = 2 : Error getting process list
 | @error = 3 : No processes found

Remarks

Supplementary to ProcessExists().

Related

ProcessExists

Example

#include <Process.au3>

Run("notepad.exe")
WinWaitActive("Untitled - Notepad", "")
$pid = WinGetProcess("Untitled - Notepad", "")
$name = _ProcessGetName($pid)

MsgBox(0, "Notepad - " & $pid, $name)


Function _ProcessGetPriority

Function Reference

_ProcessGetPriority

Get the priority of an open process

#include <Process.au3>
_ProcessGetPriority ($i_PID)

Parameters

$i_PID Process ID (Int) of process to be examined.

Return Value

Success: | Returns integer corressponding to the processes's priority:
 | 0 - Idle/Low
 | 1 - Below Normal (Not supported on Windows 95/98/ME)
 | 2 - Normal
 | 3 - Above Normal (Not supported on Windows 95/98/ME)
 | 4 - High
 | 5 - Realtime
Failure: | Returns -1 and sets @Error to 1

Remarks

None.

Related

ProcessSetPriority

Example

#include<process.au3>

Dim $i_Priority_Level, $i_Notepad_PID, $i_ArrayItem
Dim $a_RunLevels[3] = [0, 2, 4] ;low, normal, high priorities
;Get Priority Level of this instance of AutoIt Scripting Engine
$i_Priority_Level = _ProcessGetPriority (@AutoItPID)
MsgBox(0, "AutoIt Script", "Should be 2: " & $i_Priority_Level)
$i_Notepad_PID = Run(@ComSpec & ' /k notepad.exe', '', @SW_HIDE)
For $i_ArrayItem = 0 To 2
ProcessSetPriority($i_Notepad_PID, $a_RunLevels[$i_ArrayItem])
$i_Priority_Level = _ProcessGetPriority ($i_Notepad_PID)
MsgBox(0, "Notepad Priority", "Should be " & $a_RunLevels[$i_ArrayItem] & ": " & $i_Priority_Level)
Next
ProcessClose('notepad.exe')


Function _RunDOS

Function Reference

_RunDOS

Executes a DOS command in a hidden command window.

#include <Process.au3>
_RunDOS ( $sCommand )

Parameters

$sCommand Command to execute

Return Value

Success: | Returns the exit code of the command
Failure: | Depends on RunErrorsFatal setting

Remarks

None.

Related

None.

Example

#include <Process.au3>
$rc = _RunDos("start Http://www.autoitscript.com")


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: Sound Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_SoundClose | Closes a sound previously opened with _SoundOpen.
_SoundLength | Returns the length of the soundfile.
_SoundOpen | Opens a sound file for use with other _Sound functions.
_SoundPause | Pause a playing sound.
_SoundPlay | Play a sound file.
_SoundPos | Returns the current position of the sound.
_SoundResume | Resume a paused sound.
_SoundSeek | Seeks the sound to the specified position
_SoundStatus | Returns the status of the sound
_SoundStop | Stop a playing sound.


Function _SoundClose

Function Reference

_SoundClose

Closes a sound previously opened with _SoundOpen.

#include <Sound.au3>
_SoundClose ( $sSnd_id )

Parameters

$sSnd_id Sound ID (the 'alias') as returned by _SoundOpen

Return Value

Success: | 1
Failure: | 0
@Error: | 0 = No Error
 | 1 = Failure

Remarks

None.

Related

_SoundOpen

Example

#include <Sound.au3>
;open sound file
$sound = _SoundOpen(@WindowsDir & "\media\Windows XP Startup.wav", "Startup")
If @error = 2 Then
MsgBox(0, "Error", "The file does not exist")
Exit
ElseIf @error = 3 Then
MsgBox(0, "Error", "The alias was invalid")
Exit
ElseIf @extended <> 0 Then
$extended = @extended ;assign because @extended will be set after DllCall
$stText = DllStructCreate("char[128]")
$errorstring = DllCall("winmm.dll","short","mciGetErrorStringA","str",$extended,"ptr",DllStructGetPtr($stText),"int",128)
MsgBox(0, "Error", "The open failed." & @CRLF & "Error Number: " & $extended & @CRLF & "Error Description: " & DllStructGetData($stText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
MsgBox(0, "Success", "The file opened successfully")
EndIf

If _SoundClose($sound) = 1 Then
MsgBox(0, "Success", "The sound was closed successfully")
Else
MsgBox(0, "Error", "The file was not closed successfully")
EndIf


Function _SoundLength

Function Reference

_SoundLength

Returns the length of the soundfile.

#include <Sound.au3>
_SoundLength ( $sSnd_id [, $iMode ] )

Parameters

$sSnd_id | Sound ID (the 'alias') as returned by _SoundOpen or a file
$iMode | [optional] This flag determines which format the length of the sound is returned in 1 = hh:mm:ss where h = hours, m = minutes and s = seconds 2 = milliseconds

Return Value

Success: | Sound Length
Failure: | 0
@Error: | 0 = No Error
 | 1 = $iMode is invalid

Remarks

None.

Related

_SoundPos

Example

#include <Sound.au3>
;open sound file
$sound = _SoundOpen(@WindowsDir & "\media\Windows XP Startup.wav", "Startup")
If @error = 2 Then
MsgBox(0, "Error", "The file does not exist")
Exit
ElseIf @error = 3 Then
MsgBox(0, "Error", "The alias was invalid")
Exit
ElseIf @extended <> 0 Then
$extended = @extended ;assign because @extended will be set after DllCall
$stText = DllStructCreate("char[128]")
$errorstring = DllCall("winmm.dll","short","mciGetErrorStringA","str",$extended,"ptr",DllStructGetPtr($stText),"int",128)
MsgBox(0, "Error", "The open failed." & @CRLF & "Error Number: " & $extended & @CRLF & "Error Description: " & DllStructGetData($stText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
MsgBox(0, "Success", "The file opened successfully")
EndIf
MsgBox(0, "Sound Length", "The Sound has a length of:" & @CRLF & "hh:mm:ss - " & _
_SoundLength($sound, 1) & @CRLF & "Milliseconds - " & _SoundLength($sound, 2))


Function _SoundOpen

Function Reference

_SoundOpen

Opens a sound file for use with other _Sound functions.

#include <Sound.au3>
_SoundOpen ( $hFile [, $sAlias ] )

Parameters

$hFile | Path to sound file
$sAlias | Optional - A name given to the sound which is used in other functions.

Return Value

Success: | Sound ID
Failure: | 0
@Error: | 0 = No Error
 | 2 = File does not exist
 | 3 = alias contains whitespace
@Extended: | 0 = No Error
 | Integer other than 0 = MCI Error

Remarks

None.

Related

_SoundClose

Example

#include <Sound.au3>
;open sound file
$sound = _SoundOpen(@WindowsDir & "\media\Windows XP Startup.wav", "Startup")
If @error = 2 Then
MsgBox(0, "Error", "The file does not exist")
Exit
ElseIf @error = 3 Then
MsgBox(0, "Error", "The alias was invalid")
Exit
ElseIf @extended <> 0 Then
$extended = @extended ;assign because @extended will be set after DllCall
$stText = DllStructCreate("char[128]")
$errorstring = DllCall("winmm.dll","short","mciGetErrorStringA","str",$extended,"ptr",DllStructGetPtr($stText),"int",128)
MsgBox(0, "Error", "The open failed." & @CRLF & "Error Number: " & $extended & @CRLF & "Error Description: " & DllStructGetData($stText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
MsgBox(0, "Success", "The file opened successfully")
EndIf
_SoundClose($sound)


Function _SoundPause

Function Reference

_SoundPause

Pause a playing sound.

#include <Sound.au3>
_SoundPause ( $sSnd_id )

Parameters

$sSnd_id Sound ID (the 'alias') as returned by _SoundOpen or a file

Return Value

Success: | 1
Failure: | 0
@Error: | 0 = No Error
 | 1 = Pause Failed

Remarks

None.

Related

_SoundResume

Example

#include <Sound.au3>
;open sound file
$sound = _SoundOpen(@WindowsDir & "\media\Windows XP Startup.wav", "Startup")
If @error = 2 Then
MsgBox(0, "Error", "The file does not exist")
Exit
ElseIf @error = 3 Then
MsgBox(0, "Error", "The alias was invalid")
Exit
ElseIf @extended <> 0 Then
$extended = @extended ;assign because @extended will be set after DllCall
$stText = DllStructCreate("char[128]")
$errorstring = DllCall("winmm.dll","short","mciGetErrorStringA","str",$extended,"ptr",DllStructGetPtr($stText),"int",128)
MsgBox(0, "Error", "The open failed." & @CRLF & "Error Number: " & $extended & @CRLF & "Error Description: " & DllStructGetData($stText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
MsgBox(0, "Success", "The file opened successfully")
EndIf
_SoundPlay($sound)
Sleep(1000)
_SoundPause($sound)
Sleep(1000)
_SoundResume($sound)
While 1
Sleep(100)
If _SoundPos($sound, 2) = _SoundLength($sound, 2) Then ExitLoop
WEnd

_SoundClose($sound)


Function _SoundPlay

Function Reference

_SoundPlay

Play a sound file.

#include <Sound.au3>
_SoundPlay ( $sSnd_id [, $fWait ] )

Parameters

$sSnd_id | Sound ID (the 'alias') as returned by _SoundOpen or a file
$fWait | [optional] This flag determines if the script should wait for the sound to finish before continuing: 1 = wait until sound has finished 0 = continue script while sound is playing (default)

Return Value

Success: | 1
Failure: | 0
@Error: | 0 = No Error
 | 1 = Play Failed
 | 2 = $fWait parameter is invalid

Remarks

None.

Related

_SoundPause, _SoundStop, _SoundSeek

Example

#include <Sound.au3>
;open sound file
$sound = _SoundOpen(@WindowsDir & "\media\Windows XP Startup.wav", "Startup")
If @error = 2 Then
MsgBox(0, "Error", "The file does not exist")
Exit
ElseIf @error = 3 Then
MsgBox(0, "Error", "The alias was invalid")
Exit
ElseIf @extended <> 0 Then
$extended = @extended ;assign because @extended will be set after DllCall
$stText = DllStructCreate("char[128]")
$errorstring = DllCall("winmm.dll","short","mciGetErrorStringA","str",$extended,"ptr",DllStructGetPtr($stText),"int",128)
MsgBox(0, "Error", "The open failed." & @CRLF & "Error Number: " & $extended & @CRLF & "Error Description: " & DllStructGetData($stText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
MsgBox(0, "Success", "The file opened successfully")
EndIf
_SoundPlay($sound, 1)

_SoundClose($sound)


Function _SoundPos

Function Reference

_SoundPos

Returns the current position of the sound.

#include <Sound.au3>
_SoundPos ( $sSnd_id [, $iMode ] )

Parameters

$sSnd_id | Sound ID (the 'alias') as returned by _SoundOpen or a file
$iMode | [optional] This flag determines which format the position of the sound is returned in 1 = hh:mm:ss where h = hours, m = minutes and s = seconds 2 = milliseconds

Return Value

Success: | Sound Position
Failure: | 0
@Error: | 0 = No Error
 | 1 = $iMode is invalid

Remarks

None.

Related

_SoundLength

Example

#include <Sound.au3>
;open sound file
$sound = _SoundOpen(@WindowsDir & "\media\Windows XP Startup.wav", "Startup")
If @error = 2 Then
MsgBox(0, "Error", "The file does not exist")
Exit
ElseIf @error = 3 Then
MsgBox(0, "Error", "The alias was invalid")
Exit
ElseIf @extended <> 0 Then
$extended = @extended ;assign because @extended will be set after DllCall
$stText = DllStructCreate("char[128]")
$errorstring = DllCall("winmm.dll","short","mciGetErrorStringA","str",$extended,"ptr",DllStructGetPtr($stText),"int",128)
MsgBox(0, "Error", "The open failed." & @CRLF & "Error Number: " & $extended & @CRLF & "Error Description: " & DllStructGetData($stText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
MsgBox(0, "Success", "The file opened successfully")
EndIf
_SoundPlay($sound, 0)
$splashtext = SplashTextOn("Current Position", _SoundPos($sound, 1), 300, 90, Default, Default, 18, Default, 55)
While 1
Sleep(100)
ControlSetText("Current Position", "", "Static1", _SoundPos($sound, 1))
If _SoundPos($sound, 2) = _SoundLength($sound, 2) Then ExitLoop
WEnd
_SoundClose($sound)


Function _SoundResume

Function Reference

_SoundResume

Resume a paused sound.

#include <Sound.au3>
_SoundResume ( $sSnd_id )

Parameters

$sSnd_id Sound ID (the 'alias') as returned by _SoundOpen or a file

Return Value

Success: | 1
Failure: | 0
@Error: | 0 = No Error
 | 1 = Pause Failed

Remarks

_SoundPlay will also resume playing after a sound has been paused in some cases.

Related

_SoundPause, _SoundPlay

Example

#include <Sound.au3>
;open sound file
$sound = _SoundOpen(@WindowsDir & "\media\Windows XP Startup.wav", "Startup")
If @error = 2 Then
MsgBox(0, "Error", "The file does not exist")
Exit
ElseIf @error = 3 Then
MsgBox(0, "Error", "The alias was invalid")
Exit
ElseIf @extended <> 0 Then
$extended = @extended ;assign because @extended will be set after DllCall
$stText = DllStructCreate("char[128]")
$errorstring = DllCall("winmm.dll","short","mciGetErrorStringA","str",$extended,"ptr",DllStructGetPtr($stText),"int",128)
MsgBox(0, "Error", "The open failed." & @CRLF & "Error Number: " & $extended & @CRLF & "Error Description: " & DllStructGetData($stText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
MsgBox(0, "Success", "The file opened successfully")
EndIf
_SoundPlay($sound)
Sleep(1000)
_SoundPause($sound)
Sleep(1000)
_SoundResume($sound)
While 1
Sleep(100)
If _SoundPos($sound, 2) = _SoundLength($sound, 2) Then ExitLoop
WEnd

_SoundClose($sound)


Function _SoundSeek

Function Reference

_SoundSeek

Seeks the sound to the specified position

#include <Sound.au3>
_SoundSeek ( $sSnd_id, $iHour, $iMin, $iSec )

Parameters

$sSnd_id | Sound ID (the 'alias') as returned by _SoundOpen
$iHour | Hour to seek to
$iMin | Minute to seek to
$iSec | Second to seek to

Return Value

Success: | 1
Failure: | 0
@Error: | 0 = No Error
 | 1 = Failure

Remarks

After using _SoundSeek on a sound, you must use _SoundPlay to resume playing

Related

_SoundPlay

Example

#include <Sound.au3>
;open sound file
$sound = _SoundOpen(@WindowsDir & "\media\Windows XP Startup.wav", "Startup")
If @error = 2 Then
MsgBox(0, "Error", "The file does not exist")
Exit
ElseIf @error = 3 Then
MsgBox(0, "Error", "The alias was invalid")
Exit
ElseIf @extended <> 0 Then
$extended = @extended ;assign because @extended will be set after DllCall
$stText = DllStructCreate("char[128]")
$errorstring = DllCall("winmm.dll","short","mciGetErrorStringA","str",$extended,"ptr",DllStructGetPtr($stText),"int",128)
MsgBox(0, "Error", "The open failed." & @CRLF & "Error Number: " & $extended & @CRLF & "Error Description: " & DllStructGetData($stText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
MsgBox(0, "Success", "The file opened successfully")
EndIf
_SoundPlay($sound, 0)
Sleep(1000)
;seek to 2 seconds into song
_SoundSeek($sound, 0, 0, 2)
_SoundPlay($sound, 0)
While 1
Sleep(100)
If _SoundPos($sound, 2) = _SoundLength($sound, 2) Then ExitLoop
WEnd

_SoundClose($sound)


Function _SoundStatus

Function Reference

_SoundStatus

Returns the status of the sound

#include <Sound.au3>
_SoundStatus ( $sSnd_id )

Parameters

$sSnd_id Sound ID (the 'alias') as returned by _SoundOpen or a file

Return Value

Success: | Sound Status
Failure: | 0
@Error: | 0 = No Error

Remarks

From MSDN:
All devices can return the "not ready", "paused", "playing", and "stopped" values.
Some devices can return the additional "open", "parked", "recording", and "seeking" values.

Related

Example

#include <Sound.au3>
;open sound file
$sound = _SoundOpen(@WindowsDir & "\media\Windows XP Startup.wav", "Startup")
If @error = 2 Then
MsgBox(0, "Error", "The file does not exist")
Exit
ElseIf @error = 3 Then
MsgBox(0, "Error", "The alias was invalid")
Exit
ElseIf @extended <> 0 Then
$extended = @extended ;assign because @extended will be set after DllCall
$stText = DllStructCreate("char[128]")
$errorstring = DllCall("winmm.dll","short","mciGetErrorStringA","str",$extended,"ptr",DllStructGetPtr($stText),"int",128)
MsgBox(0, "Error", "The open failed." & @CRLF & "Error Number: " & $extended & @CRLF & "Error Description: " & DllStructGetData($stText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
MsgBox(0, "Success", "The file opened successfully")
EndIf

ConsoleWrite("After _SoundOpen: ")
ConsoleWrite(_SoundStatus($sound) & @LF)

_SoundPlay($sound)
ConsoleWrite("After _SoundPlay: ")
ConsoleWrite(_SoundStatus($sound) & @LF)

Sleep(1000)

_SoundPause($sound)
ConsoleWrite("After _SoundPause: ")
ConsoleWrite(_SoundStatus($sound) & @LF)

Sleep(1000)
_SoundResume($sound)

While 1
Sleep(100)
If _SoundPos($sound, 2) = _SoundLength($sound, 2) Then ExitLoop
WEnd

_SoundClose($sound)


Function _SoundPlay

Function Reference

_SoundPlay

Stop a playing sound.

#include <Sound.au3>
_SoundStop ( $sSnd_id )

Parameters

$sSnd_id Sound ID (the 'alias') as returned by _SoundOpen or a file

Return Value

Success: | 1
Failure: | 0
@Error: | 0 = No Error
 | 1 = Stop Failed

Remarks

None.

Related

_SoundPlay

Example

#include <Sound.au3>
;open sound file
$sound = _SoundOpen (@WindowsDir & "\media\Windows XP Startup.wav", "Startup")
If @error = 2 Then
MsgBox(0, "Error", "The file does not exist")
Exit
ElseIf @error = 3 Then
MsgBox(0, "Error", "The alias was invalid")
Exit
ElseIf @extended <> 0 Then
$extended = @extended ;assign because @extended will be set after DllCall
$stText = DllStructCreate("char[128]")
$errorstring = DllCall("winmm.dll","short","mciGetErrorStringA","str",$extended,"ptr",DllStructGetPtr($stText),"int",128)
MsgBox(0, "Error", "The open failed." & @CRLF & "Error Number: " & $extended & @CRLF & "Error Description: " & DllStructGetData($stText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
Else
MsgBox(0, "Success", "The file opened successfully")
EndIf
_SoundPlay ($sound)
While 1
If _SoundPos ($sound, 2) = 1000 Then
_SoundStop ($sound)
ExitLoop
EndIf
WEnd

_SoundClose ($sound)


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: SQLite Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_SQLite_Changes | Returns number of changes (excluding triggers) of the last transaction
_SQLite_Close | Close a SQLite database.
_SQLite_Display2DResult | Returns or prints a 2Dimensional array formated to Console
_SQLite_Encode | Encodes strings or binary data for use in SQLite query's
_SQLite_ErrCode | Returns last error code (numeric)
_SQLite_ErrMsg | Returns a string describing in english the error condition for the most recent sqlite3_* API call
_SQLite_Escape | Escapes a string
_SQLite_Exec | Executes a SQLite query, does not handle results.
_SQLite_FetchData | Fetches 1 row of data from a _SQLite_Query() based query
_SQLite_FetchNames | Read out the table names of a _SQLite_Query() based query
_SQLite_GetTable | Passes Out a 1Dimensional Array Containing Tablenames and Data of Executed Query.
_SQLite_GetTable2d | Passes out a 2Dimensional array containing table names and data of executed Query
_SQLite_LastInsertRowID | Returns the ROWID of the most recent insert in the database
_SQLite_LibVersion | Returns the version number of the library
_SQLite_Open | Opens/creates a SQLite database.
_SQlite_Query | Prepares a SQLite Query
_SQLite_QueryFinalize | Finalizes an _SQLite_Query() based query. The query is interrupted.
_SQlite_QueryReset | Reset a _SQLite_Query() based query
_SQLite_QuerySingleRow | Read out the first row of the result from the specified query.
_SQLite_SaveMode | Disable or Enable Save mode
_SQLite_SetTimeout | Sets timeout for busy handler
_SQLite_Shutdown | Unloads SQLite.dll
_SQLite_SQLiteExe | Executes commands in SQLite.exe
_SQLite_Startup | Loads SQLite.dll
_SQLite_TotalChanges | Returns number of all changes (including triggers) of all transactions


Function _SQLite_Changes

Function Reference

_SQLite_Changes

Returns number of changes (excluding triggers) of the last transaction

#include <SQLite.au3>
_SQLite_Changes ( [ $hDB ] )

Parameters

$hDB [optional] An open database, default is the last opened database

Return Value

Success: | Returns number of changes
Failure: | Returns 0
@error | 1 - Error calling SQLite API 'sqlite3_changes'
 | 2 - Call prevented by SaveMode

Remarks

None.

Related

None.

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

_SQLite_Startup()
_SQLite_Open()
_SQLite_Exec(-1,"CREATE TABLE test (a, b);") ; Create Table
_SQLite_Exec(-1,"INSERT INTO test VALUES ('1', '2');") ; Insert Row 1
_SQLite_Exec(-1,"INSERT INTO test VALUES ('3', '4');") ; Insert Row 2
MsgBox(0,"SQLite","The Last Query changed " & _SQLite_Changes() & " Rows" & @CR & _
"All Query changed " & _SQLite_TotalChanges() & " Rows")
_SQLite_Close()
_SQLite_Shutdown()


Function _SQLite_Close

Function Reference

_SQLite_Close

Close a SQLite database.

#include <SQLite.au3>
_SQLite_Close ( [ $hDB ] )

Parameters

$hDB [optional] Database handle.

Return Value

Success: | Returns $SQLITE_OK.
Failure: | Return value can be compared against $SQLITE_* constants.
@error | -1 - SQLite reported an error (Check Return value)
 | 1 - Error calling SQLite API 'sqlite3_close'
 | 2 - Call prevented by SaveMode

Remarks

If no database handle is given, the last opened database will be closed.

Related

_SQLite_Open

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

_SQLite_Startup ()
If @error > 0 Then
MsgBox(16, "SQLite Error", "SQLite.dll Can't be Loaded!")
Exit - 1
EndIf
_SQLite_Open () ; Open a :memory: database
If @error > 0 Then
MsgBox(16, "SQLite Error", "Can't Load Database!")
Exit - 1
EndIf
_SQLite_Close ()
_SQLite_Shutdown ()


Function _SQLite_Display2DResult

Function Reference

_SQLite_Display2DResult

Returns or prints a 2Dimensional array formated to Console

#include <SQLite.au3>
_SQLite_Display2DResult ( $aResult [, $iCellWidth = 0 [, $fReturn = False ]] )

Parameters

$aResult | The array to be displayed
$iCellWidth | [optional] specifies the size of a data field
$fReturn | [optional] if true the formated string is returned

Return Value

Success: | none or formated string
Failure: | @error = 1 - $aResult is no array or has wrong dimension

Remarks

None.

Related

_SQLite_GetTable2d

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $aResult, $iRows, $iColumns, $iRval

_SQLite_Startup ()
If @error > 0 Then
MsgBox(16, "SQLite Error", "SQLite.dll Can't be Loaded!")
Exit - 1
EndIf
_SQLite_Open () ; Open a :memory: database
If @error > 0 Then
MsgBox(16, "SQLite Error", "Can't Load Database!")
Exit - 1
EndIf

;Example Table
; Name | Age
; -----------------------
; Alice | 43
; Bob | 28
; Cindy | 21

If Not _SQLite_Exec (-1, "CREATE TEMP TABLE persons (Name, Age);") = $SQLITE_OK Then _
MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())
If Not _SQLite_Exec (-1, "INSERT INTO persons VALUES ('Alice','43');") = $SQLITE_OK Then _
MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())
If Not _SQLite_Exec (-1, "INSERT INTO persons VALUES ('Bob','28');") = $SQLITE_OK Then _
MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())
If Not _SQLite_Exec (-1, "INSERT INTO persons VALUES ('Cindy','21');") = $SQLITE_OK Then _
MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())

; Query
$iRval = _SQLite_GetTable2d (-1, "SELECT * FROM persons;", $aResult, $iRows, $iColumns)
If $iRval = $SQLITE_OK Then
_SQLite_Display2DResult($aResult)

;~ $aResult looks like this:
;~
;~ Name Age
;~ Alice 43
;~ Bob 28
;~ Cindy 21
;~
;~ If the dimensions would be switched in _SQLite_GetTable2d the result would look like this:
;~
;~ Name Alice Bob Cindy
;~ Age 43 28 21

Else
MsgBox(16, "SQLite Error: " & $iRval, _SQLite_ErrMsg ())
EndIf

_SQLite_Close ()
_SQLite_Shutdown ()


Function _SQLite_Encode

Function Reference

_SQLite_Encode

Encodes strings or binary data for use in SQLite query's

#include <SQLite.au3>
_SQLite_Encode ( $vData )

Parameters

$vData Data To be encoded (String, Number or Binary)

Return Value

Success: | Returns encoded string
Failure: | Returns empty string and sets @error to 1

Remarks

The encoded string is already wrapped with single quotes.
For example chr(0) & chr(1) would look like X'0001'
The encoded string is decoded by Sqlite which stores the data in binary state.

Related

_SQLite_Escape

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $hFile, $vData, $sFileName, $sData, $hQuery, $aRow, $sMsg
_SQLite_Startup()
_SQLite_Open()
_SQLite_Exec(-1,"CREATE TABLE IF NOT EXISTS Test (data blob);")
$vData = Binary("Hello" & Chr(0) & "World"); = 48656C6C6F00576F726C64
$sData = _SQLite_Encode($vData)
_SQLite_Exec(-1,"INSERT INTO Test VALUES (" & $sData & ");")
$vData = Binary(Chr(0) & @CRLF); = 000D0A
$sData = _SQLite_Encode($vData)
_SQLite_Exec(-1,"INSERT INTO Test VALUES (" & $sData & ");")
$vData = Binary(Chr(0)); = 00 but this is interpreted as Number and returns 0000000000000000
$sData = _SQLite_Encode($vData)
_SQLite_Exec(-1,"INSERT INTO Test VALUES ( " & $sData & " );")
_SQLite_Query(-1,"SELECT * FROM Test;",$hQuery)
While _SQLite_FetchData ($hQuery, $aRow, 1) = $SQLITE_OK
$sMsg &= Hex($aRow[0]) & @CR
WEnd
MsgBox(0,"Result",$sMsg)
_SQLite_Close()
_SQLite_Shutdown()


Function _SQLite_ErrCode

Function Reference

_SQLite_ErrCode

Returns last error code (numeric)

#include <SQLite.au3>
_SQLite_ErrCode ( [ $hDB ] )

Parameters

$hDB [optional] An open database, default is the last opened database

Return Value

Success: | Return value can be compared against $SQLITE_* constants
Failure: | Returns 0
@error | 1 - error calling SQLite API 'sqlite3_errcode'

Remarks

None.

Related

_SQLite_ErrMsg

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

_SQLite_Startup()
_SQLite_Open()
If $SQLITE_OK <> _SQLite_Exec(-1,"CREATE TABLE test ('a', 'b);") Then _ ; a Quote is missing
MsgBox(0,"SQLite Error","Error Code: " & _SQLite_ErrCode() & @CR & "Error Message: " & _SQLite_ErrMsg())
_SQLite_Close()
_SQLite_Shutdown()


Function _SQLite_ErrMsg

Function Reference

_SQLite_ErrMsg

Returns a string describing in english the error condition for the most recent sqlite3_* API call

#include <SQLite.au3>
_SQLite_ErrMsg ( [ $hDB ] )

Parameters

$hDB {optional] An open database, default is the last opened database

Return Value

Success: | Returns error message
Failure: | @error = 1 - error calling SQLite API 'sqlite3_errmsg'

Remarks

None.

Related

_SQLite_ErrCode

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

_SQLite_Startup()
_SQLite_Open()
If $SQLITE_OK <> _SQLite_Exec(-1,"CREATE TABLE test ('a', 'b);") Then _ ; a Quote is missing
MsgBox(0,"SQLite Error","Error Code: " & _SQLite_ErrCode() & @CR & "Error Message: " & _SQLite_ErrMsg())
_SQLite_Close()
_SQLite_Shutdown()


Function _SQLite_Escape

Function Reference

_SQLite_Escape

Escapes a string

#include <SQLite.au3>
_SQLite_Escape ( $sString [, $iBuffSize ] )

Parameters

$sString | string to escape
$iBuffSize | [optional] the result will be truncated if its longer

Return Value

Success: | Returns escaped string
Failure: | Returns empty string and sets @error to 1

Remarks

The escaped string is already wrapped with single quotes.
For example "It's a fine day" would look like "It''s a fine day"
For binary data use _SQLite_Encode()

Related

_SQLite_Encode

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

_SQLite_Startup()
Local $sTestString,$i,$aRow
For $i = 1 To 255
$sTestString &= Chr($i)
Next
_SQLite_Open()
_SQLite_Exec(-1,"CREATE TABLE test (a)")
_SQLite_Exec(-1,"INSERT INTO test VALUES (" & _SQLite_Escape($sTestString) & ")")
_SQLite_QuerySingleRow(-1,"SELECT a FROM test LIMIT 1",$aRow)
If $aRow[0] = $sTestString Then ConsoleWrite("! identical !" & @LF)
_SQLite_Shutdown()


Function _SQLite_Exec

Function Reference

_SQLite_Exec

Executes a SQLite query, does not handle results.

#include <SQLite.au3>
_SQLite_Exec ( $hDB, $sSQL [, $sCallBack ] )

Parameters

$hDB | An open database, use -1 to use last opened database
$sSQL | SQL statement to be executed
$sCallback | [optional] if specified the function will be called for each row

Return Value

Success: | Returns $SQLITE_OK
Failure: | Return value can be compared against $SQLITE_* constants
@error | -1 - SQLite reported an error (Check return value)
 | 1 - Error calling SQLite API 'sqlite3_exec'
 | 2 - Call prevented by SaveMode
 | 3 - Error processing Callback

Remarks

The Callback function must accept 1 parameter and can return $SQLITE_ABORT to stop processing (See example).
The first row in the Callback sequence will be the column names.

Related

_SQLite_Query

Example

#include <sqlite.au3>
#include <sqlite.dll.au3>

Local $hQuery,$aRow
_SQLite_Startup()
_SQLite_Open()
; Whithout $sCallback its an Resultless query
_SQLite_Exec(-1,"Create table tblTest (a,b int,c single not null);" & _
"Insert into tblTest values ('1',2,3);" & _
"Insert into tblTest values (Null,5,6);")

$d = _SQLite_Exec(-1,"Select oid,* From tblTest","_cb") ; _cb Will be called for each row
Func _cb($aRow)
For $s In $aRow
ConsoleWrite($s & @TAB)
Next
ConsoleWrite(@LF)
; Return $SQLITE_ABORT ; Would Abort the process and trigger an @error in _SQLite_Exec()
EndFunc
_SQLite_Close()
_SQLite_Shutdown()

; Output:
;~ rowid a b c
;~ 1 1 2 3
;~ 2 5 6


Function _SQLite_FetchData

Function Reference

_SQLite_FetchData

Fetches 1 row of data from a _SQLite_Query() based query

#include <SQLite.au3>
_SQLite_FetchData ( $hQuery, ByRef $aRow [, $fBinary ] )

Parameters

$hQuery | Queryhandle passed out by _SQLite_Query()
$aRow | A 1 dimensional array containing a row of data
$fBinary | [optional] Switch for binary mode ($aRow will be a array of binary strings)

Return Value

Success: | Returns $SQLITE_OK
Failure: | Return value can be compared against $SQLITE_* constants
@error | -1 - SQLite reported an error (Check return value)
 | 1 - Error calling SQLite API 'sqlite3_step'
 | 2 - Error calling SQLite API 'sqlite3_data_count'
 | 3 - Error calling SQLite API 'sqlite3_column_text'
 | 4 - Error calling SQLite API 'sqlite3_column_type'
 | 5 - Error calling SQLite API 'sqlite3_column_bytes'
 | 6 - Error calling SQLite API 'sqlite3_column_blob'
 | 7 - Call prevented by SaveMode

Remarks

None.

Related

_SQLite_Query

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $hQuery, $aRow, $aNames
_SQLite_Startup ()
_SQLite_Open () ; open :memory: Database
_SQLite_Exec (-1, "CREATE TABLE aTest (a,b,c);")
_SQLite_Exec (-1, "INSERT INTO aTest(a,b,c) VALUES ('c','2','World');")
_SQLite_Exec (-1, "INSERT INTO aTest(a,b,c) VALUES ('b','3',' ');")
_SQLite_Exec (-1, "INSERT INTO aTest(a,b,c) VALUES ('a','1','Hello');")
_SQlite_Query (-1, "SELECT ROWID,* FROM aTest ORDER BY a;", $hQuery)
_SQLite_FetchNames ($hQuery, $aNames)
ConsoleWrite(StringFormat(" %-10s %-10s %-10s %-10s ", $aNames[0], $aNames[1], $aNames[2], $aNames[3]) & @CR)
While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK ; Read Out the next Row
ConsoleWrite(StringFormat(" %-10s %-10s %-10s %-10s ", $aRow[0], $aRow[1], $aRow[2], $aRow[3]) & @CR)
WEnd
_SQLite_Exec (-1, "DROP TABLE aTest;")
_SQLite_Close ()
_SQLite_Shutdown ()

;~ Output:
;~
;~ rowid a b c
;~ 3 a 1 Hello
;~ 2 b 3
;~ 1 c 2 World


Function _SQLite_FetchNames

Function Reference

_SQLite_FetchNames

Read out the table names of a _SQLite_Query() based query

#include <SQLite.au3>
_SQLite_FetchNames ( $hQuery, ByRef $aNames )

Parameters

$hQuery | Query handle generated by SQLite_Query()
$aNames | 1 dimensional array containing the table names

Return Value

Success: | Returns $SQLITE_OK
Failure: | Return value can be compared against $SQLITE_* constants
@error | -1 - SQLite reported an error (Check return value)
 | 1 - Error calling SQLite API 'sqlite3_data_count'
 | 2 - Error calling SQLite API 'sqlite3_column_name'
 | 3 - Call prevented by SaveMode

Remarks

None.

Related

_SQLite_Query

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $hQuery, $aRow, $aNames
_SQLite_Startup ()
_SQLite_Open () ; open :memory: Database
_SQLite_Exec (-1, "CREATE TABLE aTest (a,b,c);")
_SQLite_Exec (-1, "INSERT INTO aTest(a,b,c) VALUES ('c','2','World');")
_SQLite_Exec (-1, "INSERT INTO aTest(a,b,c) VALUES ('b','3',' ');")
_SQLite_Exec (-1, "INSERT INTO aTest(a,b,c) VALUES ('a','1','Hello');")
_SQlite_Query (-1, "SELECT ROWID,* FROM aTest ORDER BY a;", $hQuery)
_SQLite_FetchNames ($hQuery, $aNames) ; Read out Column Names
ConsoleWrite(StringFormat(" %-10s %-10s %-10s %-10s ", $aNames[0], $aNames[1], $aNames[2], $aNames[3]) & @CR)
While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK
ConsoleWrite(StringFormat(" %-10s %-10s %-10s %-10s ", $aRow[0], $aRow[1], $aRow[2], $aRow[3]) & @CR)
WEnd
_SQLite_Exec (-1, "DROP TABLE aTest;")
_SQLite_Close ()
_SQLite_Shutdown ()

;~ Output:
;~
;~ rowid a b c
;~ 3 a 1 Hello
;~ 2 b 3
;~ 1 c 2 World


Function _SQLite_GetTable

Function Reference

_SQLite_GetTable

Passes Out a 1Dimensional Array Containing Tablenames and Data of Executed Query.

#include <SQLite.au3>
_SQLite_GetTable ( $hDB, $sSQL, ByRef $aResult, ByRef $iRows, ByRef $iColumns [, $iCharSize = 64 ] )

Parameters

$hDB | An open database, use -1 To use last opened database
$sSQL | SQL Statement to be executed
$aResult | Passes out the result
$iRows | Passes out the amount of 'data' Rows
$iColumns | Passes out the amount of columns
$iCharSize | [optional] Specifies the maximal size of a data field

Return Value

Success: | Returns $SQLITE_OK
Failure: | Return value can be compared against $SQLITE_* constants
@error | -1 - SQLite reported an error (Check Return value)
 | 1 - Error calling SQLite API 'sqlite3_get_table'
 | 2 - Error calling SQLite API 'sqlite3_free_table'
 | 3 - Call prevented by SaveMode

Remarks

The number of values inserted into $aResult will be (($iRows) + 1) * ($iColumns)
this number is inserted into $aResult[0].
A NULL will be returned as numeric 0
This Function uses more memory than _SQlite_Query() / _SQLite_Fetch*()... but it's faster.
If you do not need a result (or if there will be none) consider using
_SQLite_Execute() or _SQLite_Exec().

Related

_SQLite_GetTable2d, _SQLite_Exec, _SQlite_Query

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <Array.au3>

Local $aResult, $iRows, $iColumns, $iRval

_SQLite_Startup ()
If @error > 0 Then
MsgBox(16, "SQLite Error", "SQLite.dll Can't be Loaded!")
Exit - 1
EndIf
_SQLite_Open () ; Open a :memory: database
If @error > 0 Then
MsgBox(16, "SQLite Error", "Can't Load Database!")
Exit - 1
EndIf

;Example Table
; Name | Age
; -----------------------
; Alice | 43
; Bob | 28
; Cindy | 21

If Not _SQLite_Exec (-1, "CREATE TEMP TABLE persons (Name, Age);") = $SQLITE_OK Then _
MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())
If Not _SQLite_Exec (-1, "INSERT INTO persons VALUES ('Alice','43');") = $SQLITE_OK Then _
MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())
If Not _SQLite_Exec (-1, "INSERT INTO persons VALUES ('Bob','28');") = $SQLITE_OK Then _
MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())
If Not _SQLite_Exec (-1, "INSERT INTO persons VALUES ('Cindy','21');") = $SQLITE_OK Then _
MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())

; Query
$iRval = _SQLite_GetTable (-1, "SELECT * FROM persons;", $aResult, $iRows, $iColumns)
If $iRval = $SQLITE_OK Then
;~ $aResult Looks Like this:
;~ [0] = 8
;~ [1] = Name
;~ [2] = Age
;~ [3] = Alice
;~ [4] = 43
;~ [5] = Bob
;~ [6] = 28
;~ [7] = Cindy
;~ [8] = 21
_ArrayDisplay($aResult, "Query Result")
Else
MsgBox(16, "SQLite Error: " & $iRval, _SQLite_ErrMsg ())
EndIf

_SQLite_Close ()
_SQLite_Shutdown ()


Function _SQLite_GetTable2d

Function Reference

_SQLite_GetTable2d

Passes out a 2Dimensional array containing table names and data of executed Query

#include <SQLite.au3>
_SQLite_GetTable2d ( $hDB, $sSQL, ByRef $aResult, ByRef $iRows, ByRef $iColumns [, $iCharSize [, $fSwichDimensions = False ]] )

Parameters

$hDB | An Open Database, Use -1 To use Last Opened Database
$sSQL | SQL Statement to be executed
$aResult | Passes out the result
$iRows | Passes out the amount of 'data' Rows
$iColumns | Passes out the amount of columns
$iCharSize | [optional] Specifies the maximal size of a data field
$fSwichDimensions | [optional] Switches dimensions of $aResult

Return Value

Success: | Returns $SQLITE_OK
Failure: | Return value can be compared against $SQLITE_* constants
@error | -1 - SQLite reported an error (Check Return value)
 | 1 - Error calling SQLite API 'sqlite3_get_table'
 | 2 - Error calling SQLite API 'sqlite3_free_table'
 | 3 - Call prevented by SaveMode

Remarks

The number of values inserted into $aResult will be (($iRows) + 1) * ($iColumns)
A NULL will be returned as Numeric 0
This function uses more memory
than _SQlite_Query() / _SQLite_Fetch*()... but it's Faster.
If you do not need a result (or if there will be none) consider using SQLite_Exec().

Related

_SQLite_GetTable, _SQLite_Exec, _SQlite_Query, _SQLite_Display2DResult

Example

#include <SQLite.au3>
Local $aResult, $iRows, $iColumns, $iRval

_SQLite_Startup ()
If @error > 0 Then
MsgBox(16, "SQLite Error", "SQLite.dll Can't be Loaded!")
Exit - 1
EndIf
_SQLite_Open () ; Open a :memory: database
If @error > 0 Then
MsgBox(16, "SQLite Error", "Can't Load Database!")
Exit - 1
EndIf

;Example Table
; Name | Age
; -----------------------
; Alice | 43
; Bob | 28
; Cindy | 21

If Not _SQLite_Exec (-1, "CREATE TEMP TABLE persons (Name, Age);") = $SQLITE_OK Then _
MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())
If Not _SQLite_Exec (-1, "INSERT INTO persons VALUES ('Alice','43');") = $SQLITE_OK Then _
MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())
If Not _SQLite_Exec (-1, "INSERT INTO persons VALUES ('Bob','28');") = $SQLITE_OK Then _
MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())
If Not _SQLite_Exec (-1, "INSERT INTO persons VALUES ('Cindy','21');") = $SQLITE_OK Then _
MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())

; Query
$iRval = _SQLite_GetTable2d (-1, "SELECT * FROM persons;", $aResult, $iRows, $iColumns)
If $iRval = $SQLITE_OK Then
_SQLite_Display2DResult($aResult)

;~ $aResult looks like this:
;~
;~ Name Age
;~ Alice 43
;~ Bob 28
;~ Cindy 21
;~
;~ If the dimensions would be switched in _SQLite_GetTable2d the result would look like this:
;~
;~ Name Alice Bob Cindy
;~ Age 43 28 21

Else
MsgBox(16, "SQLite Error: " & $iRval, _SQLite_ErrMsg ())
EndIf

_SQLite_Close ()
_SQLite_Shutdown ()


Function _SQLite_LastInsertRowID

Function Reference

_SQLite_LastInsertRowID

Returns the ROWID of the most recent insert in the database

#include <SQLite.au3>
_SQLite_LastInsertRowID ( [ $hDB ] )

Parameters

$hDB [optional] An open database, use -1 to use last opened database

Return Value

Success: | Returns ROWID
Failure: | Returns 0
@error | 1 - Error calling SQLite API 'sqlite3_last_insert_rowid'
 | 2 - Call prevented by SaveMode

Remarks

None.

Related

None.

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <Array.au3>

Local $aResult, $iRows, $iColumns, $iRval

_SQLite_Startup ()
If @error > 0 Then
MsgBox(16, "SQLite Error", "SQLite.dll Can't be Loaded!")
Exit - 1
EndIf
_SQLite_Open () ; Open a :memory: database
If @error > 0 Then
MsgBox(16, "SQLite Error", "Can't Load Database!")
Exit - 1
EndIf

;Example Table
; Name | Age
; -----------------------
; Alice | 43
; Bob | 28
; Cindy | 21

; _SQLite_Exec() and _SQLite_Execute() are quite similar
If Not _SQLite_Exec (-1, "CREATE TEMP TABLE persons (Name, Age);") = $SQLITE_OK Then _
MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())
If Not _SQLite_Exec (-1, "INSERT INTO persons VALUES ('Alice','43');") = $SQLITE_OK Then _
MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())
If Not _SQLite_Exec (-1, "INSERT INTO persons VALUES ('Bob','28');") = $SQLITE_OK Then _
MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())
If Not _SQLite_Exec (-1, "INSERT INTO persons VALUES ('Cindy','21');") = $SQLITE_OK Then _
MsgBox(16, "SQLite Error", _SQLite_ErrMsg ())

; _SQLite_LastInsertRowID() tells us Cindy's row
MsgBox( 0, "_SQLite_LastInsertRowID()", _SQLite_LastInsertRowID() )

; Query
$iRval = _SQLite_GetTable (-1, "SELECT * FROM persons;", $aResult, $iRows, $iColumns)
If $iRval = $SQLITE_OK Then
;~ $aResult Looks Like this:
;~ [0] = 8
;~ [1] = Name
;~ [2] = Age
;~ [3] = Alice
;~ [4] = 43
;~ [5] = Bob
;~ [6] = 28
;~ [7] = Cindy
;~ [8] = 21
_ArrayDisplay($aResult, "Query Result")
Else
MsgBox(16, "SQLite Error: " & $iRval, _SQLite_ErrMsg ())
EndIf

_SQLite_Close ()
_SQLite_Shutdown ()


Function _SQLite_LibVersion

Function Reference

_SQLite_LibVersion

Returns the version number of the library

#include <SQLite.au3>
_SQLite_LibVersion ( )

Parameters

None.

Return Value

Success: | Returns version number
Failure: | @error = 1

Remarks

Requieres SQLite.dll in Current or System directory.

Related

None.

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

_SQLite_Startup ()
If @error > 0 Then
MsgBox(16, "SQLite Error", "SQLite.dll Can't be Loaded!")
Exit - 1
EndIf
_SQLite_Open () ; Open a :memory: database
If @error > 0 Then
MsgBox(16, "SQLite Error", "Can't Load Database!")
Exit - 1
EndIf
MsgBox(0,"SQLite Version",_SQLite_LibVersion())
_SQLite_Close ()
_SQLite_Shutdown ()


Function _SQLite_Open

Function Reference

_SQLite_Open

Opens/creates a SQLite database.

#include <SQLite.au3>
_SQLite_Open ( [ $sDatabase_Filename = ":memory:" ] )

Parameters

$sDatabase_Filename [optional] Database filename, by default will opens an in memory database.

Return Value

Success: | Returns database handle.
Failure: | Returns 0.
@extended | value can be compared against $SQLITE_* constants
@error | 1 - Error calling SQLite API 'sqlite3_open'
 | -1 - SQLite reported an error (Check @extended value)

Remarks

There is no need to store the database handle.
Functions that use the handle are using the last opened by default.

Related

_SQLite_Close

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

_SQLite_Startup ()
If @error > 0 Then
MsgBox(16, "SQLite Error", "SQLite.dll Can't be Loaded!")
Exit - 1
EndIf
_SQLite_Open () ; Open a :memory: database
If @error > 0 Then
MsgBox(16, "SQLite Error", "Can't Load Database!")
Exit - 1
EndIf
_SQLite_Close ()
_SQLite_Shutdown ()


Function _SQLite_Query

Function Reference

_SQLite_Query

Prepares a SQLite Query

#include <SQLite.au3>
_SQLite_Query ( $hDB, $sSQL, ByRef $hQuery )

Parameters

$hDB | An open database, use -1 to use last opened database
$sSQL | SQL statement to be executed
$hQuery | Passes out a query handle

Return Value

Success: | Returns $SQLITE_OK
Failure: | Return value can be compared against $SQLITE_* constants
@error | -1 - SQLite reported an error (Check return value)
 | 1 - Error calling SQLite API 'sqlite3_prepare'
 | 2 - Call prevented by SafeMode

Remarks

None.

Related

_SQLite_FetchData, _SQLite_FetchNames

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $hQuery, $aRow, $sMsg
_SQLite_Startup ()
_SQLite_Open () ; open :memory: Database
_SQLite_Exec (-1, "CREATE TABLE aTest (a,b,c);") ; CREATE a Table
_SQLite_Exec (-1, "INSERT INTO aTest(a,b,c) VALUES ('c','2','World');") ; INSERT Data
_SQLite_Exec (-1, "INSERT INTO aTest(a,b,c) VALUES ('b','3',' ');") ; INSERT Data
_SQLite_Exec (-1, "INSERT INTO aTest(a,b,c) VALUES ('a','1','Hello');") ; INSERT Data
_SQlite_Query (-1, "SELECT c FROM aTest ORDER BY a;", $hQuery) ; the query
While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK
$sMsg &= $aRow[0]
WEnd
_SQLite_Exec (-1, "DROP TABLE aTest;") ; Remove the table
MsgBox(0,"SQLite","Get Data using a Query : " & $sMsg )
_SQLite_Close()
_SQLite_Shutdown()

;~ Output:
;~
;~ Hello World


Function _SQLite_QueryFinalize

Function Reference

_SQLite_QueryFinalize

Finalizes an _SQLite_Query() based query. The query is interrupted.

#include <SQLite.au3>
_SQLite_QueryFinalize ( $hQuery )

Parameters

$hQuery Query handle generated by SQLite_Query()

Return Value

Success: | Returns $SQLITE_OK
Failure: | Return value can be compared against $SQLITE_* constants
@error | -1 - SQLite reported an Error (Check Return value)
 | 1 - Error calling SQLite API 'sqlite3_finalize'
 | 2 - Call prevented by SaveMode

Remarks

The _SQLite_QueryFinalize function is called to delete a prepared SQL statement obtained by a previous call to _SQLite_Query. If the statement was executed successfully, or not executed at all, then SQLITE_OK is returned. If execution of the statement failed then an error code is returned.

All prepared statements must finalized before _SQLite_Close is called or else the close will fail with a return code of SQLITE_BUSY.

Related

_SQLite_Query

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $hQuery, $aRow, $aNames
_SQLite_Startup ()
_SQLite_Open () ; open :memory: Database
_SQLite_Exec (-1, "CREATE TABLE aTest (a,b,c);")
_SQLite_Exec (-1, "INSERT INTO aTest(a,b,c) VALUES ('c','2','World');")
_SQLite_Exec (-1, "INSERT INTO aTest(a,b,c) VALUES ('b','3',' ');")
_SQLite_Exec (-1, "INSERT INTO aTest(a,b,c) VALUES ('a','1','Hello');")
_SQlite_Query (-1, "SELECT ROWID,* FROM aTest ORDER BY a;", $hQuery)
_SQLite_FetchNames ($hQuery, $aNames) ; Read out the Tablenames
MsgBox(0,"SQLite","Row ID is : " & StringFormat(" %-10s %-10s %-10s %-10s ", $aNames[0], $aNames[1], $aNames[2], $aNames[3]) & @CR)
While _SQLite_FetchData ($hQuery, $aRow) = $SQLITE_OK ; This get 1 row at a time
MsgBox(0,"SQLite","Get Data using FetchData : " & StringFormat(" %-10s %-10s %-10s %-10s ", $aRow[0], $aRow[1], $aRow[2], $aRow[3]) & @CR)
_SQLite_QueryFinalize ($hQuery) ; This will stop the query, getting more rows
WEnd
_SQLite_Exec (-1, "DROP TABLE aTest;")
_SQLite_Close ()
_SQLite_Shutdown ()

;~ Output:
;~
;~ rowid a b c
;~ 3 a 1 Hello


Function _SQLite_QueryReset

Function Reference

_SQLite_QueryReset

Reset a _SQLite_Query() based query

#include <SQLite.au3>
_SQLite_QueryReset ( $hQuery )

Parameters

$hQuery Query handle generated by SQLite_Query()

Return Value

Success: | Returns $SQLITE_OK
Failure: | Return value can be compared against $SQLITE_* constants
@error | -1 - SQLite reported an error (Check Return value)
 | 1 - Error calling SQLite API 'sqlite3_reset'
 | 2 - Call prevented by SaveMode

Remarks

If you want to re-execute the same query with different parameters, you should just use sqlite3_reset() instead of sqlite3_finalize(). This will reset the query so that it is ready to be executed again.

Related

_SQLite_Query

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $hQuery, $aRow, $iSwitch
_SQLite_Startup()
_SQLite_Open()
_SQLite_Exec(-1,"CREATE TABLE tblTest (a,b,c);")
_SQLite_Exec(-1,"INSERT INTO tblTest VALUES ('1','1','1');" & _ ; Row 1
"INSERT INTO tblTest VALUES ('2','2','2');" & _ ; Row 2
"INSERT INTO tblTest VALUES ('3','3','3');") ; Row 3
_SQLite_Query(-1,"SELECT RowID,* FROM tblTest;",$hQuery)
While _SQLite_FetchData($hQuery,$aRow) = $SQLITE_OK
$iSwitch = MsgBox(4+64, "Row: " & $aRow[0], $aRow[1] & "," & $aRow[2] & "," & $aRow[3] & @LF & _
"Continue Looping?")
If $iSwitch = 6 Then ; Yes
If $aRow[0] = 3 Then _SQLite_QueryReset($hQuery)
Else ; No
_SQLite_QueryFinalize($hQuery)
ExitLoop
EndIf
WEnd
_SQLite_Close()
_SQLite_Shutdown()


Function _SQLite_QuerySingleRow

Function Reference

_SQLite_QuerySingleRow

Read out the first row of the result from the specified query.

#include <SQLite.au3>
_SQLite_QuerySingleRow ( $hDB, $sSQL, ByRef $aRow )

Parameters

$hDB | An open database, use -1 to use last opened database
$sSQL | SQL statement to be executed
$aRow | Passes out the amount of 'data' rows

Return Value

Success: | Returns $SQLITE_OK
Failure: | Return value can be compared against $SQLITE_* constants
@error | -1 - SQLite Reported an Error (Check Return value)
 | 1 - Error calling SQLite API 'sqlite3_get_table'
 | 2 - Error calling SQLite API 'sqlite3_free_table'
 | 3 - Call prevented by SaveMode

Remarks

None.

Related

_SQLite_Query

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $aRow
_SQLite_Startup ()
_SQLite_Open () ; open :memory: Database
_SQLite_Exec(-1,"CREATE TEMP TABLE settings (key,value);")
_SQLite_Exec(-1,"INSERT INTO settings (key,value) VALUES ('1','setting one');")
_SQLite_Exec(-1,"INSERT INTO settings (key,value) VALUES ('2','setting two');")
_SQLite_Exec(-1,"INSERT INTO settings (key,value) VALUES ('3','setting Three');")
_SQLite_Exec(-1,"INSERT INTO settings (key,value) VALUES ('4','setting Four');")
_SQLite_QuerySingleRow(-1,"SELECT value FROM settings WHERE key = '2' LIMIT 1;",$aRow) ; Select single row and single field !
MsgBox(0,"setting two:",$aRow[0])
_SQLite_Close ()
_SQLite_Shutdown ()


Function _SQLite_SaveMode

Function Reference

_SQLite_SaveMode

Disable or Enable Save mode

#include <SQLite.au3>
_SQLite_SaveMode ( $fSaveModeState )

Parameters

$fSaveModeState True or False to enable or disable SafeMode

Return Value

Success: | Returns $SQLITE_OK
Failure: | Returns $SQLITE_MISUSE and sets @error = 1

Remarks

Save mode prevents SQLite from crashing which can be caused by passing invalid query or database handles.
It's enabled by default.

Related

None.

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

_SQLite_Startup()
_SQLite_SaveMode(False)
_SQLite_Exec(-1,"CREATE tblTest (a,b,c);"); No database openend, this will crash
_SQLite_Shutdown()


Function _SQLite_SetTimeout

Function Reference

_SQLite_SetTimeout

Sets timeout for busy handler

#include <SQLite.au3>
_SQLite_SetTimeout ( [ $hDB = -1 [, $iTimeout = 1000 ]] )

Parameters

$hDB | An open database, use -1 to use last opened database
$iTimeout | Timeout [msec]

Return Value

Success: | Returns $SQLITE_OK
Failure: | Return value can be compared against $SQLITE_* constants
@error | -1 - SQLite reported an error (Check Return value)
 | 1 - Error calling SQLite API 'sqlite3_busy_timeout'
 | 2 - Call prevented by SaveMode

Remarks

This routine sets a busy handler that sleeps for a while when a table is locked. The handler will sleep multiple times until at least "ms" milliseconds of sleeping have been done. After "ms" milliseconds of sleeping, the handler returns 0 which causes sqlite3_exec() to return SQLITE_BUSY.

Related

_SQLite_Query

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <File.au3>

_SQLite_Startup()

Local $sDatabase, $hDB_a, $hDB_b, $iTimer, $iRval
$sDatabase = _TempFile()
$hDB_a = _SQLite_Open($sDatabase)
$hDB_b = _SQLite_Open($sDatabase)

_SQLite_Exec($hDB_a,"BEGIN EXCLUSIVE;")
_SQLite_Exec($hDB_a,"CREATE TABLE test (a,b,c);")
_SQLite_Exec($hDB_a,"INSERT INTO test VALUES (1,2,3);")
; Table 'test' is Busy now...

_SQLite_SetTimeout($hDB_b,0)
$iTimer = TimerInit()
$iRval = _SQLite_Exec($hDB_b,"SELECT * FROM test") ; This will fail
MsgBox(0,"_SQLite_SetTimeout Example No Timeout", "Time: " & TimerDiff($iTimer) & @LF _
& "Error: " & _SQLite_ErrMsg($hDB_b) & @LF)
_SQLite_SetTimeout($hDB_b,5000)
$iTimer = TimerInit()
$iRval = _SQLite_Exec($hDB_b,"SELECT * FROM test") ; This will fail
MsgBox(0,"_SQLite_SetTimeout Example 5 Sec Timeout", "Time: " & TimerDiff($iTimer) & @LF _
& "Error: " & _SQLite_ErrMsg($hDB_b) & @LF)
_SQLite_Exec($hDB_a,"END;")
_SQLite_Close($hDB_a)
_SQLite_Close($hDB_b)
_SQLite_Shutdown()
FileDelete($sDatabase)


Function _SQLite_Shutdown

Function Reference

_SQLite_Shutdown

Unloads SQLite.dll

#include <SQLite.au3>
_SQLite_Shutdown ( )

Parameters

None.

Return Value

None.

Remarks

If _SQLite_Startup() failed or was not executed, an AutoIt runtime error will be thrown, and the script will terminate!
AutoIt automatically closes any dlls it opened, but calling _SQLite_Shutdown is still a good idea.

Related

_SQLite_Startup

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>
_SQLite_Startup ()
If @error > 0 Then
MsgBox(16, "SQLite Error", "SQLite.dll Can't be Loaded!")
Exit - 1
EndIf
_SQLite_Shutdown ()


Function _SQLite_SQLiteExe

Function Reference

_SQLite_SQLiteExe

Executes commands in SQLite.exe

#include <SQLite.au3>
_SQLite_SQLiteExe ( $sDatabaseFile, $sInput, ByRef $sOutput [, $sSQLiteExeFilename = "SQLite3.exe" ] )

Parameters

$sDatabaseFile | Database filename
$sInput | Commands for SQLite.exe
$sOutput | Raw output from SQLite.exe
$sSQLiteExeFilename | [optional] Path to SQlite.exe

Return Value

Success: | Returns $SQLITE_OK
Failure: | Return value can be compared against $SQLITE_* constants
@error | 1 - Cant create new Database
 | 2 - SQLite3.exe not Found
 | 3 - SQL error / incomplete SQL
 | 4 - Cant open input file

Remarks

Run SQLite.exe, press enter and type .Help for more info about the SQLite3.exe Commands.

SQLite3.exe can be found at the SQLite Web site. A copy with an help file can be found in AutoIt3\Extras\SQLite dir.

Related

None.

Example

#include <sqlite.au3>
#include <file.au3>

;Filenames
Local $sTsvFile = FileGetShortName(_TempFile(@ScriptDir,"~",".tsv"))
Local $sDbFile = FileGetShortName(_TempFile(@ScriptDir,"~",".db"))

;Create Tsv File
FileWriteLine($sTsvFile,"a" & @TAB & "b" & @TAB & "c")
FileWriteLine($sTsvFile,"a1" & @TAB & "b1" & @TAB & "c1")
FileWriteLine($sTsvFile,"a2" & @TAB & "b2" & @TAB & "c2")

;import (using SQLite3.exe)
Local $sIn,$sOut,$i, $sCreate = "CREATE TABLE TblImport (";
for $i = 1 To _StringCountOccurance(FileReadLine($sTsvFile,1),@TAB) + 1
$sCreate &= "Column_" & $i & ","
Next
$sCreate = StringTrimRight($sCreate,1) & ");"
$sIn = $sCreate & @CRLF ; Create Table
$sIn &= ".separator \t" & @CRLF ; Select @TAB as Separator
$sIn &= ".import '" & $sTsvFile & "' TblImport" & @CRLF
_SQLite_SQLiteExe($sDbFile,$sIn,$sOut)

If @error = 0 Then
;Show Table (using SQLite3.dll)
Local $iRows,$iColumns,$aRes
_SQLite_Startup()
_SQLite_Open($sDbFile)
_SQLite_GetTable2d(-1,"SELECT ROWID,* FROM TblImport;",$aRes,$iRows,$iColumns)
_SQLite_Display2DResult($aRes) ; Output to Console
_SQLite_Close()
_SQLite_Shutdown()
Else
If @error = 2 Then
ConsoleWrite("ERROR: Sqlite3.exe file not found" & @LF)
Else
ConsoleWrite("ERROR: @error=" & @error & " when calling _SQLite_SQLiteExe" & @LF)
EndIf
EndIf

;Remove Temp Files
FileDelete($sTsvFile)
FileDelete($sDbFile)

;~ Output:
;~ rowid Column_1 Column_2 Column_3
;~ 1 a b c
;~ 2 a1 b1 c1
;~ 3 a2 b2 c2

Func _StringCountOccurance($sSearchString,$sSubString,$fCaseSense = 0) ; Returns Number of $sSubString in $sSearchString
Local $iOccCnt = 1
Do
If StringInStr($sSearchString,$sSubString,$fCaseSense,$iOccCnt) > 0 Then
$iOccCnt += 1
Else
ExitLoop
EndIf
Until 0
Return $iOccCnt - 1
EndFunc


Function _SQLite_Startup

Function Reference

_SQLite_Startup

Loads SQLite.dll

#include <SQLite.au3>
_SQLite_Startup ( [ $sDll_Filename = "sqlite3.dll" ] )

Parameters

$sDll_Filename [optional] Dll filename

Return Value

Success: | Returns path to SQLite3.dll
Failure: | @error = 1

Remarks

Requieres SQLite3.dll in @ScriptDir or @SystemDir.

If SQLite3.dll.au3 is included the dll will be created in @SystemDir.
If not successfull a temporary file will be created that will be destroyed at _SQLite_Shutdown().

Related

_SQLite_Shutdown

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $sSQliteDll
$sSQliteDll = _SQLite_Startup ()
If @error > 0 Then
MsgBox(16, "SQLite Error", "SQLite.dll Can't be Loaded!")
Exit - 1
EndIf
MsgBox(0,"SQLite3.dll Loaded",$sSQliteDll)
_SQLite_Shutdown ()


Function _SQLite_TotalChanges

Function Reference

_SQLite_TotalChanges

Returns number of all changes (including triggers) of all transactions

#include <SQLite.au3>
_SQLite_TotalChanges ( [ $hDB ] )

Parameters

$hDB [optional] An open database, default is the last opened database

Return Value

Success: | Returns number of changes
Failure: | Returns 0.
@error | 1 - Error calling SQLite API 'sqlite3_changes'
 | 2 - Call prevented by SaveMode

Remarks

None.

Related

None.

Example

#include <SQLite.au3>
#include <SQLite.dll.au3>

_SQLite_Startup()
_SQLite_Open()
_SQLite_Exec(-1,"CREATE TABLE test (a, b);") ; Create Table
_SQLite_Exec(-1,"INSERT INTO test VALUES ('1', '2');") ; Insert Row 1
_SQLite_Exec(-1,"INSERT INTO test VALUES ('3', '4');") ; Insert Row 2
MsgBox(0,"SQLite","The Last Query changed " & _SQLite_Changes() & " Rows" & @CR & _
"All Query changed " & _SQLite_TotalChanges() & " Rows")
_SQLite_Close()
_SQLite_Shutdown()


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: String Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_HexToString | Convert a hex string to a string.
_StringAddComma | Returns the original numbered string with the proper delimiter inserted.
_StringBetween | Returns the string between the start search string and the end search string.
_StringEncrypt | An RC4 based string encryption function.
_StringInsert | Inserts a string within another string.
_StringProper | Changes a string to proper case, same a =Proper function in Excel
_StringRepeat | Repeats a string a specified number of times.
_StringReverse | Reverses the contents of the specified string.
_StringToHex | Convert a string to a hex string.


Function _HexToString

Function Reference

_HexToString

Convert a hex string to a string.

#include <String.au3>
_HexToString ( strHex )

Parameters

strHex
an hexadecimal string

Return Value

Success: | Returns a string.
Failure: | Returns -1 and sets @error to 1.

Remarks

None.

Related

_StringToHex

Example

#include <string.au3>
$String = "I like AutoIt3"
$Hex = _StringToHex($String)
MsgBox(0, "Hex", "Original String: " & $String & @LF & " Hex: " & $Hex)

$Hex = "49206C696B65204175746F497433"
$String = _HexToString($Hex)
MsgBox(0, "Hex", "Original Hex: " & $Hex & @LF & " String: " & $String)


Function _StringAddComma

Function Reference

_StringAddComma

Returns the original numbered string with the proper delimiter inserted.

#include <String.au3>
_StringAddComma ( $sStr [, $sSeparator [, $sEnd ]] )

Parameters

$sStr | The string to be converted.
$sSeperator | Optional: The delimiter to separate the string of numbers. Default=','
$sEnd | Optional: The decimal delimiter. Default='.'

Return Value

Success: | The string delimited.
Failure: | 0
@Error: | 0 = No error.
 | 1 = Not a numbered string

Remarks

None.

Related

None.

Example

#include <String.au3>
$nAmount = 89996.31
$sDelimted = _StringAddComma($nAmount)
MsgBox(64, 'Info', $sDelimted)

$nAmt = '38849230'
$sDelim = _StringAddComma($nAmt)
MsgBox(64, 'Info', $sDelim)


Function _StringBetween

Function Reference

_StringBetween

Returns the string between the start search string and the end search string.

#include <String.au3>
_StringBetween ( $sString, $sStart, $sEnd [, $vCase [, $iSRE ]] )

Parameters

$sString | The string to search.
$sStart | The beginning of the string to find
$sEnd | The end of the string to find
$vCase | Optional: Case sensitive search. Default or -1 is not Case sensitive else Case sensitive.
$iSRE | Optional: Toggle for regular string manipulation or StringRegExp search. Default is regular string manipulation.

Return Value

Success: | A 0 based $array[0] contains the first found string.
Failure: | 0
@Error: | 1 = No inbetween string found.

Remarks

None.

Related

None.

Example

#include <String.au3>
#include <array.au3>
$aArray1 = _StringBetween('[18][20][3][5][500][60]', '[', ']');Not using SRE
_ArrayDisplay($aArray1, 'Default Search')
$aArray2 = _StringBetween('[18][20][3][5][500][60]', '\[', '\]', -1, 1);Using SRE
_ArrayDisplay($aArray2, 'StringRegExp Search')


Function _StringEncrypt

Function Reference

_StringEncrypt

An RC4 based string encryption function.

#include <String.au3>
_StringEncrypt ( $i_Encrypt, $s_EncryptText, $s_EncryptPassword [, $i_EncryptLevel ] )

Parameters

$i_Encrypt | 1 to encrypt, 0 to decrypt.
$s_EncryptText | Text to encrypt/decrypt.
$s_EncryptPassword | Password to encrypt/decrypt with.
$i_EncryptLevel | Optional: Level to encrypt/decrypt. Default = 1

Return Value

Success: | The Encrypted/Decrypted string.
Failure: | Blank string and @error = 1

Remarks

WARNING: This function has an extreme timespan if the encryption level or encrypted string are too large!

Related

None.

Example

#include <guiconstants.au3>
#include <string.au3>
; GUI and String stuff
$WinMain = GuiCreate('Encryption tool', 400, 400)
; Creates window
$EditText = GuiCtrlCreateEdit('',5,5,380,350)
; Creates main edit
$InputPass = GuiCtrlCreateInput('',5,360,100,20, 0x21)
; Creates the password box with blured/centered input
$InputLevel = GuiCtrlCreateInput(1, 110, 360, 50, 20, 0x2001)
$UpDownLevel = GUICtrlSetLimit(GuiCtrlCreateUpDown($inputlevel),10,1)
; These two make the level input with the Up|Down ability
$EncryptButton = GuiCtrlCreateButton('Encrypt', 170, 360, 105, 35)
; Encryption button
$DecryptButton = GuiCtrlCreateButton('Decrypt', 285, 360, 105, 35)
; Decryption button
GUICtrlCreateLabel('Password', 5, 385)
GuiCtrlCreateLabel('Level',110,385)
; Simple text labels so you know what is what
GuiSetState()
; Shows window

Do
$Msg = GuiGetMsg()
If $msg = $EncryptButton Then
GuiSetState(@SW_DISABLE,$WinMain) ; Stops you from changing anything
$string = GuiCtrlRead($EditText) ; Saves the editbox for later
GUICtrlSetData($EditText,'Please wait while the text is Encrypted/Decrypted.') ; Friendly message
GuiCtrlSetData($EditText,_StringEncrypt(1,$string,GuiCtrlRead($InputPass),GuiCtrlRead($InputLevel)))
; Calls the encryption. Sets the data of editbox with the encrypted string
; The encryption starts with 1/0 to tell it to encrypt/decrypt
; The encryption then has the string that we saved for later from edit box
; It then reads the password box & Reads the level box
GuiSetState(@SW_ENABLE,$WinMain) ; This turns the window back on
EndIf
If $msg = $DecryptButton Then
GuiSetState(@SW_DISABLE,$WinMain) ; Stops you from changing anything
$string = GuiCtrlRead($EditText) ; Saves the editbox for later
GUICtrlSetData($EditText,'Please wait while the text is Encrypted/Decrypted.') ; Friendly message
GuiCtrlSetData($EditText,_StringEncrypt(0,$string,GuiCtrlRead($InputPass),GuiCtrlRead($InputLevel)))
; Calls the encryption. Sets the data of editbox with the encrypted string
; The encryption starts with 1/0 to tell it to encrypt/decrypt
; The encryption then has the string that we saved for later from edit box
; It then reads the password box & Reads the level box
GuiSetState(@SW_ENABLE,$WinMain) ; This turns the window back on
EndIf
Until $msg = $GUI_EVENT_CLOSE ; Continue loop untill window is closed


Function _StringInsert

Function Reference

_StringInsert

Inserts a string within another string.

#include <String.au3>
_StringInsert ( $s_String, $s_InsertString, $i_Position )

Parameters

$s_String | Original string
$s_InsertString | String to be inserted
$i_Position | Position to insert string (negatives values count from right hand side)

Return Value

Success: | Returns new modified string
Failure: | Returns original string and sets the @error to the following values:
 | @error = 1 : Source string empty
 | @error = 2 : Insert string empty
 | @error = 3 : Invalid position

Remarks

Use negative position values to insert string from the right hand side.

Related

Example

#include<string.au3>
; Inserts three "moving" underscores and prints them to the console
For $i_loop = -20 To 20
ConsoleWrite($i_loop & @TAB & _StringInsert ("Supercalifragilistic", "___", $i_loop) & @CR)
Next


Function _StringProper

Function Reference

_StringProper

Changes a string to proper case, same a =Proper function in Excel

#Include <String.au3>
_StringProper ( $sString )

Parameters

$sString Input string

Return Value

Success: | Returns proper string.
Failure: | Returns "".

Remarks

This function will capitalize every character following a None Apha character.

Related

None.

Example

#include <String.au3>
;Will return : Somebody Lastnames
Msgbox(0,'',_StringProper("somebody lastnames"))
;Will return : Some.Body Last(Name)
Msgbox(0,'',_StringProper("SOME.BODY LAST(NAME)"))
Exit


Function _StringRepeat

Function Reference

_StringRepeat

Repeats a string a specified number of times.

#Include <String.au3>
_StringRepeat ( $sString, $iRepeatCount )

Parameters

$sString | String to repeat
$iRepeatCount | Number of times to repeat the string

Return Value

Success: | Returns string with specified number of repeats
Failure: | Returns an empty string and sets @error = 1
@Error: | 0 = No error.
 | 1 = One of the parameters is invalid

Remarks

None.

Related

None.

Example

#include <String.au3>

Msgbox(0,'',_StringRepeat("+-",40))
Exit


Function _StringReverse

Function Reference

_StringReverse

Reverses the contents of the specified string.

#Include <String.au3>
_StringReverse ( $sString )

Parameters

$sString String to reverse

Return Value

Success: | Returns reversed string
Failure: | Returns an empty string and sets @error = 1
@Error: | 0 = No error.
 | 1 = One of the parameters is invalid

Remarks

None.

Related

None.

Example

#include <String.au3>
Msgbox(0,'',_StringReverse("esreveR"))
Exit


Function _StringToHex

Function Reference

_StringToHex

Convert a string to a hex string.

#include <String.au3>
_StringToHex ( string )

Parameters

string
string to be converted.

Return Value

Success: | Returns an hex string.
Failure: | Returns -1 and sets @error to 1.

Remarks

None.

Related

_HexToString

Example

#include <string.au3>
$String = "I like AutoIt3"
$Hex = _StringToHex($String)
MsgBox(0, "Hex", "Original String: " & $String & @LF & " Hex: " & $Hex)

$Hex = "49206C696B65204175746F497433"
$String = _HexToString($Hex)
MsgBox(0, "Hex", "Original Hex: " & $Hex & @LF & " String: " & $String)


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: Visa Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_viClose | Closes a VISA connection to an Instrument/Device
_viExecCommand | Send a Command/Query to an Instrument/Device through the VISA interface (GPIB / TCP)
_viFindGpib | Send a Command/Query to an Instrument/Device through the VISA interface (GPIB / TCP)
_viGpibBusReset | GPIB BUS "reset": Use this function when the GPIB BUS gets stuck for some reason. You might be lucky and resolve the problem by calling this function
_viGTL | Go To Local mode: Instruments that accept this command will exit the "Remote Control mode" and go to "Local mode". If the instrument is already in "Local mode" this is simply ignored. Normally, if an instrument does not support this command it will simply stay in the "Remote Control mode"
_viOpen | Opens a VISA connection to an Instrument/Device
_viSetAttribute | Set any VISA attribute This function, which is called by _viSetTimeout, can ALSO be used to set the other VISA specific attributes. Read the VISA documentation for more information and a list of VISA attributes and their corresponding values.
_viSetTimeout | Sets the VISA timeout in MILISECONDS


Function _viClose

Function Reference

_viClose

Closes a VISA connection to an Instrument/Device

#include <Visa.au3>
_viClose ( $h_session )

Parameters

$h_session A VISA session handle (as returned by _viOpen)

Return Value

Success: | Returns 0.
Failure: | Returns -1 if the VISA DLL could not be open or a NON ZERO value representing the VISA error code (see the VISA programmer's guide).
This function always sets @error to 1 in case of error.

Remarks

As for all the VISA functions the VISA libraries must be installed (you can check whether visa32.dll is in {WINDOWS}\system32) and a GPIB card (such as a National Instruments NI PCI-GPIB card or an Agilent 82350B PCI High-Performance GPIB card) must be installed

Related

_viClose, _viExecCommand

Example

;- This assumes that you have instrument set to GPIB address 1
; It shows how to use the _viExecCommand function in stand alone mode and combined
; with _viOpen and _viClose.
; It also shows the _viGTL function

#include <Visa.au3>

Dim $h_session = 0

; Query the ID of the instrument in GPIB address 3
MsgBox(0,"Step 1","Open the instrument connection with _viOpen")
Dim $h_instr = _viOpen("GPIB::3::0")
MsgBox(0,"Instrument Handle obtained", "$h_instr = " & $h_instr) ; Show the Session Handle
; Query the instrument

MsgBox(0,"Step 2","Query the instrument using the VISA instrument handle")
$s_answer = _viExecCommand($h_instr,"*IDN?") ; $h_instr is NOT A STRING now!
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer
; Query again. There is no need to OPEN the link again

MsgBox(0,"Step 3","Query again. There is no need to OPEN the link again")
$s_answer = _viExecCommand($h_instr,"*IDN?")
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer

MsgBox(0,"Step 4","Close the instrument connection using _viClose")
_viClose($h_instr) ; Close the instrument connection


Function _viExecCommand

Function Reference

_viExecCommand

Send a Command/Query to an Instrument/Device through the VISA interface (GPIB / TCP)

#include <Visa.au3>
_viExecCommand ( $h_session, $s_command, $i_timeout_ms = -1 )

Parameters

$h_session A VISA descriptor (STRING) OR a VISA session handle (INTEGER)
This it can be a string or an integer (a handle):
* STRING -&gr; A VISA DESCRIPTOR is a string which specifies the resource with
which to establish a communication session.
An example descriptor is "GPIB::20::0".
This function supports all valid VISA descriptors, including GPIB, TCP, VXI
and Serial Interface instruments (ASRL).
A detailed explanation of VISA descriptors is shown in the Remarks section
of this function.
As a SHORTCUT you can also use a STRING containing the address number
(e.g. "20") of a GPIB instrument instead of typing the full descriptor
(in that case, "GPIB::20::0")
* INTEGER -&gr; A VISA session handle is an integer value returned by _viOpen.
It is recommended that instead you use _viOpen and VISA session handles
instead of descriptors if you plan to communicate repeteadly with an
Instrument or Device, as otherwise each time that you contact the instrument
you would incur the overhead of opening and closing the communication link.
Once you are done using the instrument you must remember to close the link
with _viClose.
$s_command Command/Query to execute (e.g. "*IDN?" or "SOURCE:POWER -20 dBM")
A query MUST contain a QUESTION MARK (?)
When the command is a QUERY the function will automatically wait for the
instrument's answer (or until the operation times out)
$i_timeout_ms Optional: The operation timeout in MILISECONDS.
This is mostly important for QUERIES only.
This is an OPTIONAL PARAMETER.
If it is not specified the last set timeout will be used. If it was never set
before the default timeout (which depends on the VISA implementation) will be used.
Timeouts can also be set separatelly with the _viSetTimeout function.
Depending on the bus type (GPIB, TCP, etc) the timeout might not be set to the
exact value that you request. Instead the closest valid timeout bigger than
the one that you requested will be used.

Return Value

The return value depends on whether the command is a QUERY
or not and in whether the operation was successful or not.
* Command, NON QUERY:
Success: | Returns ZERO
Failure: | Returns -1 if the VISA DLL could not be open
 | or a NON ZERO value representing the VISA
 | error code (see the VISA programmer's guide)
* QUERY:
Success: | Returns the answer of the instrument to the QUERY
Failure: | Returns -1 if the VISA DLL could not be open
 | Returns -3 if the VISA DLL returned an unexpected number of results
 | or returns a NON ZERO value representing the VISA
 | error code (see the VISA programmer's guide)
This function always sets @error to 1 in case of error.

Remarks

* The VISA queries only return the 1st line of the device answer
This is not a problem in most cases, as most devices will always
answer with a single line.

* The following is a description of the MOST COMMON VISA DESCRIPTORS
Note that there are some more types. For more info please
refer to a VISA programmer's guide (available at www.ni.com)
Optional segments are shown in square brackets ([]).
Required segments that must be filled in are denoted by angle
brackets (<&gr;).

Interface Syntax
------------------------------------------------------------
GPIB INSTR GPIB[board]::primary address
[::secondary address] [::INSTR]
GPIB INTFC GPIB[board]::INTFC
TCPIP SOCKET TCPIP[board]::host address::port::SOCKET
Serial INSTR ASRL[board][::INSTR]
PXI INSTR PXI[board]::device[::function][::INSTR]
VXI INSTR VXI[board]::VXI logical address[::INSTR]
GPIB-VXI INSTR GPIB-VXI[board]::VXI logical address[::INSTR]
TCPIP INSTR TCPIP[board]::host address[::LAN device name]
[::INSTR]

The GPIB keyword is used for GPIB instruments.
The TCPIP keyword is used for TCP/IP communication.
The ASRL keyword is used for serial instruments.
The PXI keyword is used for PXI instruments.
The VXI keyword is used for VXI instruments via either embedded
or MXIbus controllers.
The GPIB-VXI keyword is used for VXI instruments via a GPIB-VXI
controller.

The default values for optional parameters are shown below.

Optional Segment Default Value
---------------------------------------
board 0
secondary address none
LAN device name inst0

Example Resource Strings:
--------------------------------------------------------------
GPIB::1::0::INSTR A GPIB device at primary address 1 and
secondary address 0 in GPIB interface 0.

GPIB2::INTFC Interface or raw resource for GPIB
interface 2.

TCPIP0::1.2.3.4::999::SOCKET Raw TCP/IP access to port 999
at the specified IP address.

ASRL1::INSTR A serial device attached to interface
ASRL1. VXI::MEMACC Board-level register
access to the VXI interface.

PXI::15::INSTR PXI device number 15 on bus 0.

VXI0::1::INSTR A VXI device at logical address 1 in VXI
interface VXI0.

GPIB-VXI::9::INSTR A VXI device at logical address 9 in a
GPIB-VXI controlled system.

Related

_viFindGpib, _viOpen, _viClose, _viSetTimeout, _viGTL, _viGpibBusReset

Example

;- This assumes that you have instrument set to GPIB address 3
; If you have an instrument in a different address change "GPIB::3::0" to the
; corresponding descriptor. Do the same for the call to _viOpen
; It shows how to use the _viExecCommand function in stand alone mode and combined
; with _viOpen and _viClose.
; It also shows the _viGTL function

#include <Visa.au3>

Dim $h_session = 0

; Query the ID of the instrument in GPIB address 3
MsgBox(0,"Step 1","Simple GPIB query using a VISA Descriptor")
Dim $s_answer = _viExecCommand("GPIB::3::0","*IDN?",10000) ; 10 secs timeout
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer

MsgBox(0,"Step 2","Go to LOCAL using VISA Descriptor")
_viGTL("GPIB::1::0") ; Go to local (exit remote control mode)

MsgBox(0,"Step 3","Simple GPIB query using a VISA address shortcut")
$s_answer = _viExecCommand("1","*IDN?") ; The address MUST BE A STRING
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer
MsgBox(0,"Info","Now let's use _viOpen and _viClose")

MsgBox(0,"Step 4","Open the instrument connection with _viOpen")
Dim $h_instr = _viOpen(3)
MsgBox(0,"Instrument Handle obtained", "$h_instr = " & $h_instr) ; Show the Session Handle
; Query the instrument

MsgBox(0,"Step 5","Query the instrument using the VISA instrument handle")
$s_answer = _viExecCommand($h_instr,"*IDN?") ; $h_instr is NOT A STRING now!
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer
; Query again. There is no need to OPEN the link again

MsgBox(0,"Step 6","Query again. There is no need to OPEN the link again")
$s_answer = _viExecCommand($h_instr,"*IDN?")
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer

MsgBox(0,"Step 7","Go to LOCAL using VISA instrument handle")
_viGTL($h_instr); Go to local (this is optional)

MsgBox(0,"Step 8","Close the Instrument connection using _viClose")
_viClose($h_instr) ; Close the instrument connection


Function _viFindGpib

Function Reference

_viFindGpib

Send a Command/Query to an Instrument/Device through the VISA interface (GPIB / TCP)

#include <Visa.au3>
_viFindGpib ( ByRef $a_descriptor_list, ByRef $a_idn_list, $f_show_search_results = 0 )

Parameters

$a_descriptor_list (ByRef) | RETURNS an array of the VISA resource descriptors of the instruments that were found in the GPIB bus (see the Remarks of the _viExecCommand for more info)
$a_idn_list (ByRef) | RETURNS an array of the IDNs (i.e names) of the instruments that were found in the GPIB bus
$f_show_search_results | Optional: If 1 a message box showing the results of the search will be shown. The default is 0, which means that the results are not shown

Return Value

Success: | The number of instruments found (0 or more)
Failure: | Returns a NEGATIVE value and SETS @error to 1

Remarks

As for all the VISA functions the VISA libraries must be installed (you can check whether visa32.dll is in {WINDOWS}\system32) and a GPIB card (such as a National Instruments NI PCI-GPIB card or an Agilent 82350B PCI High-Performance GPIB card) must be installed

* For a detailed description of the most common VISA DESCRIPTORS look at the Remarks of the help on the _viExecCommand function

Related

_viExecCommand, _viOpen, _viClose, _viGTL

Example

; This example performs a search on the GPIB bus and shows the results in a MsgBox

#include <Visa.au3>

Dim $a_descriptor_list[1], $a_idn_list[1]
_viFindGpib($a_descriptor_list, $a_idn_list, 1)


Function _viGpibBusReset

Function Reference

_viGpibBusReset

GPIB BUS "reset": Use this function when the GPIB BUS gets stuck for some reason. You might be lucky and resolve the problem by calling this function

#include <Visa.au3>
_viGpibBusReset ( )

Parameters

None

Return Value

Success: | Returns 0
Failure: | Returns -1 if the VISA DLL could not be open or a NON ZERO value representing the VISA error code (see the VISA programmer's guide)
This function always sets @error to 1 in case of error

Remarks

As for all the VISA functions the VISA libraries must be installed (you can check whether visa32.dll is in {WINDOWS}\system32) and a GPIB card (such as a National Instruments NI PCI-GPIB card or an Agilent 82350B PCI High-Performance GPIB card) must be installed

Related

_viGTL, _viExecCommand, _viFindGpib, _viOpen, _viClose

Example

; This example tries to "reset" the GPIB bus after a BUS "lock". This is rare,
; but it might happen if one of the instruments connected to the BUS has crashed

#include <Visa.au3>

_viGpibBusReset()


Function _viGTL

Function Reference

_viGTL

Go To Local mode: Instruments that accept this command will exit the "Remote Control mode" and go to "Local mode". If the instrument is already in "Local mode" this is simply ignored. Normally, if an instrument does not support this command it will simply stay in the "Remote Control mode"

#include <Visa.au3>
_viGTL ( $h_session )

Parameters

$h_session A VISA descriptor (STRING) OR a VISA session handle (INTEGER).
See the Remarks of the _viExecCommand for more info.

Return Value

Success: | Returns 0
Failure: | Returns -1 if the VISA DLL could not be open or a NON ZERO value representing the VISA error code (see the VISA programmer's guide).
This function always sets @error to 1 in case of error

Remarks

As for all the VISA functions the VISA libraries must be installed (you can check whether visa32.dll is in {WINDOWS}\system32) and a GPIB card (such as a National Instruments NI PCI-GPIB card or an Agilent 82350B PCI High-Performance GPIB card) must be installed

* For a detailed description of the most common VISA DESCRIPTORS look at the Remarks of the help on the _viExecCommand function

Related

_viExecCommand, _viGpibBusReset, _viFindGpib, _viOpen, _viClose

Example

;- This assumes that you have instrument set to GPIB address 3
; If you have an instrument in a different address change "GPIB::3::0" to the
; corresponding descriptor. Do the same for the call to _viOpen
; It shows how to use the _viGTL function with a VISA descriptor and with a
; VISA device handler. We use _viExecCommand first to force the instrument to go
; into "Remote mode"

#include <Visa.au3>

Dim $h_session = 0

; Query the ID of the instrument in GPIB address 3
MsgBox(0,"Step 1","Simple GPIB query using a VISA Descriptor")
Dim $s_answer = _viExecCommand("GPIB::3::0","*IDN?",10)
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer

MsgBox(0,"Step 2","Go to LOCAL using VISA Descriptor")
_viGTL("GPIB::1::0") ; Go to local (exit remote control mode)

MsgBox(0,"Step 4","Open the instrument connection with _viOpen")
Dim $h_instr = _viOpen(3)
MsgBox(0,"Instrument Handle obtained", "$h_instr = " & $h_instr) ; Show the Session Handle
; Query the instrument

MsgBox(0,"Step 5","Query the instrument using the VISA instrument handle")
$s_answer = _viExecCommand($h_instr,"*IDN?") ; $h_instr is NOT A STRING now!
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer
; Query again. There is no need to OPEN the link again

MsgBox(0,"Step 6","Query again. There is no need to OPEN the link again")
$s_answer = _viExecCommand($h_instr,"*IDN?")
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer

MsgBox(0,"Step 7","Go to LOCAL using VISA instrument handle")
_viGTL($h_instr); Go to local (this is optional)

MsgBox(0,"Step 8","Close the Instrument connection using _viClose")
_viClose($h_instr) ; Close the instrument connection


Function _viOpen

Function Reference

_viOpen

Opens a VISA connection to an Instrument/Device

#include <Visa.au3>
_viOpen ( $s_visa_address, $s_visa_secondary_address = 0 )

Parameters

$s_visa_address | A VISA resource descriptor STRING (see the NOTES of _viExecCommand above for more info) As as shortcut you can also directly pass a GPIB address as an integer
$s_visa_secondary_address | Optional: The "secondary GPIB address". Only used if the primary address is passed as an integer. Only some GPIB instruments have secondary addresses. In those cases this optional parameter can be used to specify it. This parameter is ZERO by default, which means NO SECONDARY ADDRESS

Return Value

Success: | Returns a (POSITIVE) VISA Instrument Handle
Failure: | Returns -1 and SETS @error to 1

Remarks

As for all the VISA functions the VISA libraries must be installed (you can check whether visa32.dll is in {WINDOWS}\system32) and a GPIB card (such as a National Instruments NI PCI-GPIB card or an Agilent 82350B PCI High-Performance GPIB card) must be installed

* For a detailed description of the most common VISA DESCRIPTORS look at the Remarks of the help on the _viExecCommand function

Related

_viClose, _viExecCommand

Example

;- This assumes that you have instrument set to GPIB address 1
; It shows how to use the _viExecCommand function in stand alone mode and combined
; with _viOpen and _viClose.
; It also shows the _viGTL function
#include <Visa.au3>
Dim $h_session = 0

; Query the ID of the instrument in GPIB address 3
MsgBox(0,"Step 1","Open the instrument connection with _viOpen")
Dim $h_instr = _viOpen("GPIB::3::0")
MsgBox(0,"Instrument Handle obtained", "$h_instr = " & $h_instr) ; Show the Session Handle
; Query the instrument

MsgBox(0,"Step 2","Query the instrument using the VISA instrument handle")
$s_answer = _viExecCommand($h_instr,"*IDN?") ; $h_instr is NOT A STRING now!
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer
; Query again. There is no need to OPEN the link again

MsgBox(0,"Step 3","Query again. There is no need to OPEN the link again")
$s_answer = _viExecCommand($h_instr,"*IDN?")
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer

MsgBox(0,"Step 4","Close the instrument connection using _viClose")
_viClose($h_instr) ; Close the instrument connection

MsgBox(0,"Step 5","Open the Instrument connection using only the address number")
Dim $h_instr = _viOpen(3)
MsgBox(0,"Instrument Handle obtained", "$h_instr = " & $h_instr) ; Show the Session Handle
; Query the instrument

MsgBox(0,"Step 6","Query the instrument using the VISA instrument handle")
$s_answer = _viExecCommand($h_instr,"*IDN?") ; $h_instr is NOT A STRING now!
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer
; Query again. There is no need to OPEN the link again

MsgBox(0,"Step 7","Query again. There is no need to OPEN the link again")
$s_answer = _viExecCommand($h_instr,"*IDN?")
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer

MsgBox(0,"Step 8","Close the instrument connection using _viClose")
_viClose($h_instr) ; Close the instrument connection


Function _viSetAttribute

Function Reference

_viSetAttribute

Set any VISA attribute This function, which is called by _viSetTimeout, can ALSO be used to set the other VISA specific attributes. Read the VISA documentation for more information and a list of VISA attributes and their corresponding values.

#include <Visa.au3>
_viSetAttribute ( $h_session, $i_attribute, $i_value )

Parameters

$h_session | A VISA descriptor (STRING) OR a VISA session handle (INTEGER). See the Remarks of the _viExecCommand for more info.
$i_attribute | The index of the attribute that must be changed. Attributes are defined in the VISA library. This AutoIt library only defines a CONSTANT for the TIMEOUT attribute ($VI_ATTR_TMO_VALUE) and for the Serial Interface attributes and values (see the remarks) but you can pass any other valid index (as an integer) if you want to.
$i_value | The value of the attribute. It must be an integer and the possible values depend on the attribute type and are defined in the VISA documentation.

Return Value

Success: | Returns 0
Failure: | Returns -1 if the VISA DLL could not be open or a NON ZERO value representing the VISA error code (see the VISA programmer's guide).
This function always sets @error to 1 in case of error.

Remarks

This is a list of the currently pre-defined attributes and values. Remember that you can use any other valid attribute/value by passing the corresponding integer index (as defined in the VISA programmer's guide) to this function.

* Attribute: $VI_ATTR_TMO_VALUE -> Set Timeout
* Values:
A timeout in MILLISECONDS or
$VI_TMO_IMMEDIATE (or 0) for "Return immediatly"
VI_TMO_INFINITE (or "INF") for "No timeout"

* Attribute: $VI_ATTR_ASRL_BAUD
* Values:
Any valid baudrate (9600, 115200, etc)

* Attribute: $VI_ATTR_ASRL_DATA_BITS
* Values:
From 5 to 8

* Attribute: $VI_ATTR_ASRL_PARITY
* Values:
$VI_ASRL_PAR_NONE
$VI_ASRL_PAR_ODD
$VI_ASRL_PAR_EVEN
$VI_ASRL_PAR_MARK
$VI_ASRL_PAR_SPACE

* Attribute: $VI_ATTR_ASRL_STOP_BITS
* Values:
$VI_ASRL_STOP_ONE
$VI_ASRL_STOP_ONE5
$VI_ASRL_STOP_TWO

* Attribute: $VI_ATTR_ASRL_FLOW_CNTRL
* Values:
$VI_ASRL_FLOW_NONE
$VI_ASRL_FLOW_XON_XOFF
$VI_ASRL_FLOW_RTS_CTS
$VI_ASRL_FLOW_DTR_DSR

As for all the VISA functions the VISA libraries must be installed (you can check whether visa32.dll is in {WINDOWS}\system32).
You onlly need a GPIB card (such as a National Instruments NI PCI-GPIB card or an Agilent 82350B PCI High-Performance GPIB card) if you use the GPIB related functions.

* For a detailed description of the most common VISA DESCRIPTORS look at the Remarks of the help on the _viExecCommand function

Related

_viSetTimeout, _viExecCommand, _viOpen, _viClose

Example

;- This assumes that you have instrument set to GPIB address 3.
; If you have an instrument in a different address change "GPIB::3::0" to the
; corresponding descriptor. Do the same for the call to _viOpen
; It shows how to use the _viSetAttribute. In this example we use _viSetAttribute
; instead of _viSetTimeout to set the GPIB timeout of a _viExecCommand operation.

#include <Visa.au3>

Dim $h_session = 0

; Query the ID of the instrument in GPIB address 3
MsgBox(0,"Step 1","Simple GPIB query with explicit TIMEOUT set")
Dim $s_answer = _viExecCommand("GPIB::3::0","*IDN?",10000) ; 10 secs timeout
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer

; This is the same as using the _viSetAttribute function first:
MsgBox(0,"Step 2","_vOpen + timeout using _viSetAttribute + GPIB query")
Dim $h_instr = _viOpen(3)
; NOTE - This is the same as: _viSetTimeout($h_instr, 10000)
_viSetAttribute($h_instr, $VI_ATTR_TMO_VALUE, 10000) ; 10000 ms = 10 secs

$s_answer = _viExecCommand($h_instr,"*IDN?") ; No need to set the timeout now
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer

MsgBox(0,"Step 3","Close the Instrument connection using _viClose")
_viClose($h_instr) ; Close the instrument connection


Function _viSetTimeout

Function Reference

_viSetTimeout

Sets the VISA timeout in MILISECONDS

#include <Visa.au3>
_viSetTimeout ( $h_session, $i_timeout_ms )

Parameters

$h_session | A VISA descriptor (STRING) OR a VISA session handle (INTEGER). See the Remarks of the _viExecCommand for more info.
$i_timeout_ms | The timeout IN MILISECONDS for VISA operations (mainly for GPIB queries) If you set it to 0 the tiemouts are DISABLED. If you set it to "INF" the VISA operations will NEVER timeout. Be careful with this as it could easly hung your program ifv your instrument does not respond to one of your queries. Depending on the bus type (GPIB, TCP, etc) the timeout might not be set to the exact value that you request. Instead the closest valid timeout bigger than the one that you requested will be used.

Return Value

Success: | Returns 0
Failure: | Returns -1 if the VISA DLL could not be open or a NON ZERO value representing the VISA error code (see the VISA programmer's guide).
This function always sets @error to 1 in case of error.

Remarks

Most of the time it is not necessary to call this function, as _viExecCommand has a third OPTIONAL parameter $i_timeout_ms which can also be used to set the VISA timeout.

As for all the VISA functions the VISA libraries must be installed (you can check whether visa32.dll is in {WINDOWS}\system32) and a GPIB card (such as a National Instruments NI PCI-GPIB card or an Agilent 82350B PCI High-Performance GPIB card) must be installed

* For a detailed description of the most common VISA DESCRIPTORS look at the Remarks of the help on the _viExecCommand function

Related

_viSetAttribute, _viExecCommand, _viOpen, _viClose

Example

;- This assumes that you have instrument set to GPIB address 3.
; If you have an instrument in a different address change "GPIB::3::0" to the
; corresponding descriptor. Do the same for the call to _viOpen
; It shows how to use the _viExecCommand function with a timeout or how to
; call _viSetTimeout instead.

#include <Visa.au3>

Dim $h_session = 0

; Query the ID of the instrument in GPIB address 3
MsgBox(0,"Step 1","Simple GPIB query with explicit TIMEOUT set")
Dim $s_answer = _viExecCommand("GPIB::3::0","*IDN?",10000) ; 10 secs timeout
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer

; This is the same as using the _viSetTimeout function first:
MsgBox(0,"Step 2","_vOpen + timeout using _viSetTimeout + GPIB query")
Dim $h_instr = _viOpen(3)
_viSetTimeout($h_instr, 10000) ; 10000 ms = 10 secs
$s_answer = _viExecCommand($h_instr,"*IDN?") ; No need to set the timeout now
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer

MsgBox(0,"Step 3","Close the Instrument connection using _viClose")
_viClose($h_instr) ; Close the instrument connection


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: Word Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_Word_VersionInfo | Returns an array of information about the Word.au3 version
_WordAttach | Attach to the first existing instance of Microsoft Word where the search string matches based on the selected mode.
_WordCreate | Create a Microsoft Office Word Object
_WordDocAdd | Returns an object variable representing a new empty document
_WordDocAddLink | Add a hyperlink to the document
_WordDocAddPicture | Add a picture to the document
_WordDocClose | Closes a previously opened word document
_WordDocFindReplace | Runs the specified find and replace operation.
_WordDocGetCollection | Returns a collection object containing all documents
_WordDocLinkGetCollection | Returns a collection object containing all links in the document
_WordDocOpen | Opens an existing Microsoft Word Document
_WordDocPrint | Prints all or part of the specified document.
_WordDocPropertyGet | Returns a select property of the Word Document.
_WordDocPropertySet | Set a select property of the Word Document
_WordDocSave | Saves a previously opened document
_WordDocSaveAs | Saves the specified document with a new name or format.
_WordErrorHandlerDeRegister | Disable a registered user COM error handler
_WordErrorHandlerRegister | Register and enable a user COM error handler
_WordErrorNotify | Specifies whether Word.au3 automatically notifies of Warnings and Errors (to the console)
_WordMacroRun | Runs a Visual Basic macro
_WordPropertyGet | Returns a select property of the Word Application.
_WordPropertySet | Set a select property of the Word Application.
_WordQuit | Close the window and remove the object reference to it


Function _Word_VersionInfo

Function Reference

_Word_VersionInfo

Returns an array of information about the Word.au3 version

#include <Word.au3>
_Word_VersionInfo ( )

Parameters

None.

Return Value

Success: | Returns an array ($WordAU3VersionInfo)
 | $WordAU3VersionInfo[0] = Release Type (T=Test or V=Production)
 | $WordAU3VersionInfo[1] = Major Version
 | $WordAU3VersionInfo[2] = Minor Version
 | $WordAU3VersionInfo[3] = Sub Version
 | $WordAU3VersionInfo[4] = Release Date (YYYYMMDD)
 | $WordAU3VersionInfo[5] = Display Version (e.g. V1.0-1)
Failure: | None

Remarks

None.

Related

None.

Example

; *******************************************************
; Example 1 - Retrieve and display Word.au3 version information
; *******************************************************
;
#include <Word.au3>
$aVersion = _Word_VersionInfo ()
MsgBox(0, "Word.au3 Version", $aVersion[5] & " released " & $aVersion[4])


Function _WordAttach

Function Reference

_WordAttach

Attach to the first existing instance of Microsoft Word where the search string matches based on the selected mode.

#include <Word.au3>
_WordAttach ( $s_string [, $s_mode = "FilePath"] )

Parameters

$s_string | String to search for
$s_mode | Optional: specifies search mode FileName = Name of the open document FilePath = (Default) Full path to the open document HWND = hwnd of the word window Text = Text from the body of the document Title = Title of the word window

Return Value

Success: | Returns an object variable pointing to the Word.Application object
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_WordStatus_Success) = No Error
 | 1 ($_WordStatus_GeneralError) = General Error
 | 5 ($_WordStatus_InvalidValue) = Invalid Value
 | 7 ($_WordStatus_NoMatch) = No Match
@Extended: | Contains invalid parameter number

Remarks

None.

Related

_WordCreate, _WordQuit

Example

; *******************************************************
; Example 1 - Attach to a word window with an open file named "Test.doc",
; then display the documents full file path.
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordAttach ("Test.doc", "FileName")
If Not @error Then
$oDoc = _WordDocGetCollection ($oWordApp, 0)
MsgBox(64, "Document FileName", $oDoc.FullName)
EndIf

; *******************************************************
; Example 2 - Attach to a word window with "The quick brown fox"
; in the text of the document
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordAttach ("The quick brown fox", "Text")


Function _WordCreate

Function Reference

_WordCreate

Create a Microsoft Office Word Object

#include <Word.au3>
_WordCreate ( [ $s_FilePath = "" [, $b_tryAttach = 0 [, $b_visible = 1 [, $b_takeFocus = 1]]]] )

Parameters

$s_FilePath | Optional: specifies the file to open upon creation (See Remarks)
$b_tryAttach | Optional: specifies whether to try to attach to an existing window 0 = (Default) do not try to attach 1 = Try to attach to an existing window
$b_visible | Optional: specifies whether the window will be visible 0 = Window is hidden 1 = (Default) Window is visible
$b_takeFocus | Optional: specifies whether to bring the attached window to focus 0 = Do Not Bring window into focus 1 = (Default) bring window into focus

Return Value

Success: | Returns an object variable pointing to a Word.Application object
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_WordStatus_Success) = No Error
 | 1 ($_WordStatus_GeneralError) = General Error
 | 3 ($_WordStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_WordStatus_InvalidObjectType) = Invalid Object Type
@Extended: | Set to true (1) or false (0) depending on the success of $f_tryAttach

Remarks

File will be created if it does not exist.

Related

_WordAttach, _WordQuit

Example

; *******************************************************
; Example 1 - Create a Microsoft Word window and open a document file
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate (@ScriptDir & "\Test.doc")

; *******************************************************
; Example 2 - Attempt to attach to an existing word window with the specified document open.
; Create a new word window and open that document if one does not already exist.
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate (@ScriptDir & "\Test.doc", 1)
; Check @extended return value to see if attach was successful
If @extended Then
MsgBox(0, "", "Attached to Existing Window")
Else
MsgBox(0, "", "Created New Window")
EndIf

; *******************************************************
; Example 3 - Create a word window with a new blank document
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate ()

; *******************************************************
; Example 4 - Create an invisible word window, open a document,
; append some text, and quit saving changes.
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate (@ScriptDir & "\Test.doc", 0, 0)
$oDoc = _WordDocGetCollection ($oWordApp, 0)
$oDoc.Range.insertAfter ("This is some text to insert.")
_WordQuit ($oWordApp, -1)


Function _WordDocAdd

Function Reference

_WordDocAdd

Returns an object variable representing a new empty document

#include <Word.au3>
_WordDocAdd ( ByRef $o_object [, $i_DocumentType = 0 [, $s_Template = "" [, $b_NewTemplate = 0]]] )

Parameters

$o_object | Object variable of a Word.Application object
$i_DocumentType | Optional: specifies the new document type 0 = (Default) blank document 1 = Web page 2 = Email Message (Currently this is non functional) 3 = Frameset 4 = XML Document
$s_Template | Optional: specifies name of the template to be used for the new document "" = (Default) normal template is used
$b_NewTemplate | Optional: specifies whether to open the document as a template 0 = (Default) do not open as template 1 = open as template

Return Value

Success: | Returns an object variable pointing to a Word.Application, document object
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_WordStatus_Success) = No Error
 | 1 ($_WordStatus_GeneralError) = General Error
 | 3 ($_WordStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_WordStatus_InvalidObjectType) = Invalid Object Type
@Extended: | Contains invalid parameter number

Remarks

None.

Related

_WordDocClose, _WordDocOpen, _WordDocSave, _WordDocSaveAs

Example

; *******************************************************
; Example 1 - Create an empty word window and add a new blank document
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate ("")
$oDoc = _WordDocAdd ($oWordApp)


Function _WordDocAddLink

Function Reference

_WordDocAddLink

Add a hyperlink to the document

#include <Word.au3>
_WordDocAddLink ( ByRef $o_object [, $o_Anchor = "" [, $s_Address = "" [, $s_SubAddress = "" [, $s_ScreenTip = "" [, $s_TextToDisplay = "" [, $s_Target = ""]]]]]] )

Parameters

$o_object | Object variable of a Word.Application, document object
$o_Anchor | Optional: The text or graphic that you want turned into a hyperlink. "" = (Default) Uses entire document as range
$s_Address | Optional: The address for the specified link. The address can be an e-mail address, an Internet address, or a file name. "" = (Default) Link to the specified document is used
$s_SubAddress | Optional: The name of a location within the destination file, such as a bookmark, named range, or slide number.
$s_ScreenTip | Optional: The text that appears as a ScreenTip when the mouse pointer is positioned over the specified hyperlink. "" = (Default) Uses value of $s_Address
$s_TextToDisplay | Optional: The display text of the specified hyperlink. The value of this argument replaces the text or graphic specified by Anchor. "" = (Default) Uses value of $s_Address
$s_Target | Optional: The name of the frame or window in which you want to load the specified hyperlink.

Return Value

Success: | Returns 1
Failure: | Retuns 0 and sets @ERROR = 1
@Error: | 0 ($_WordStatus_Success) = No Error
 | 3 ($_WordStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_WordStatus_InvalidObjectType) = Invalid Object Type
@Extended: | Contains invalid parameter number

Remarks

None.

Related

None.

Example

; *******************************************************
; Example 1 - Create a word window with a new blank document,
; add a link, then get a collection of links.
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate ()
$oDoc = _WordDocGetCollection ($oWordApp, 0)
_WordDocAddLink ($oDoc, "", "www.AutoIt3.com", "", "AutoIt" & @CRLF, "Link to AutoIt")
$oLinks = _WordDocLinkGetCollection ($oDoc)
MsgBox(0, "Link Count", @extended)


Function _WordDocAddPicture

Function Reference

_WordDocAddPicture

Add a picture to the document

#include <Word.au3>
_WordDocAddPicture ( ByRef $o_object, $s_FilePath [, $b_LinkToFile = 0 [, $b_SaveWithDocument = 0 [, $o_Range = ""]]] )

Parameters

$o_object | Object variable of a Word.Application, document object
$s_FilePath | The path and file name of the picture.
$b_LinkToFile | Optional: Specifies whether to link the picture to the file from which it was created. 0 = (Default) Make the picture an independent copy of the file 1 = Link the picture to the file from which it was created
$b_SaveWithDocument | Optional: Specifies whether to save the linked picture with the document. 0 = (Default) Do not save the linked picture with the document 1 = Save the linked picture with the document
$o_Range | Optional: The location where the picture will be placed in the text. "" = (Default) The picture is placed automatically Any range object

Return Value

Success: | Returns an object variable pointing to a Word.Application, shape object
Failure: | Retuns 0 and sets @ERROR = 1
@Error: | 0 ($_WordStatus_Success) = No Error
 | 1 ($_WordStatus_GeneralError) = General Error
 | 2 ($_WordStatus_ComError) = Com Error
 | 3 ($_WordStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_WordStatus_InvalidObjectType) = Invalid Object Type
 | 5 ($_WordStatus_InvalidValue) = Invalid Value
@Extended: | Contains invalid parameter number

Remarks

None.

Related

None.

Example

; *******************************************************
; Example 1 - Create a word window with a new blank document,
; then add some pictures to the document.
; *******************************************************
;
#include <Word.au3>

$sPath = @WindowsDir & "\"
$search = FileFindFirstFile($sPath & "*.bmp")

; Check if the search was successful
If $search = -1 Then
MsgBox(0, "Error", "No images found")
Exit
EndIf

$oWordApp = _WordCreate ()
$oDoc = _WordDocGetCollection ($oWordApp, 0)

While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
$oShape = _WordDocAddPicture ($oDoc, $sPath & $file, 0, 1)
If Not @error Then $oShape.Range.InsertAfter (@CRLF)
WEnd

; Close the search handle
FileClose($search)


Function _WordDocClose

Function Reference

_WordDocClose

Closes a previously opened word document

#include <Word.au3>
_WordDocClose ( ByRef $o_object [, $i_SaveChanges = -2 [, $i_OriginalFormat = 2 [, $b_RouteDocument = 0]]] )

Parameters

$o_object | Object variable of a Word.Application, document object
$i_SaveChanges | Optional: specifies the save action for the document 0 = Do not save changes -1 = Save changes -2 = (Default) Prompt to save changes
$i_OriginalFormat | Optional: specifies the save format for the document 0 = Word Document 1 = Original Document Format 2 = (Default) Prompt User
$b_RouteDocument | Optional: specifies whether to route the document to the next recipient 0 = (Default) do not route 1 = route to next recipient

Return Value

Success: | Returns 1
Failure: | Retuns 0 and sets @ERROR = 1
@Error: | 0 ($_WordStatus_Success) = No Error
 | 3 ($_WordStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_WordStatus_InvalidObjectType) = Invalid Object Type
@Extended: | Contains invalid parameter number

Remarks

None.

Related

_WordDocAdd, _WordDocOpen, _WordDocSave, _WordDocSaveAs

Example

; *******************************************************
; Example 1 - Create an empty word window, open an existing document,
; close the document and quit.
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate ("")
$oDoc = _WordDocOpen ($oWordApp, @ScriptDir & "\Test.doc")
_WordDocClose ($oDoc)
_WordQuit ($oWordApp)


Function _WordDocFindReplace

Function Reference

_WordDocFindReplace

Runs the specified find and replace operation.

#include <Word.au3>
_WordDocFindReplace ( ByRef $o_object [, $s_FindText = "" [, $s_ReplaceWith = "" [, $i_Replace = 2 [, $v_SearchRange = 0 [, $b_MatchCase = 0 [, $b_MatchWholeWord = 0 [, $b_MatchWildcards = 0 [, $b_MatchSoundsLike = 0 [, $b_MatchAllWordForms = 0 [, $b_Forward = 1 [, $i_Wrap = 1 [, $b_Format = 0]]]]]]]]]]]] )

Parameters

$o_object | Object variable of a Word.Application, document object
$s_FindText | Optional: The text to be searched for. (See Remarks) "" = (Default) Used to search for formatting only.
$s_ReplaceWith | Optional: The replacement text. (See Remarks) "" = (Default) Delete the text specified by $s_FindText
$i_Replace | Optional: Specifies how many replacements are to be made. 0 = Replace no occurrences 1 = Replace the first occurrence encountered 2 = (Default) Replace all occurrences
$v_SearchRange | Optional: Specifies the Selection or Range to search. -1 = Specifies the current selection 0 = (Default) Specifies the entire document Any range object
$b_MatchCase | Optional: Specifies whether the find text will be case-sensitive. 0 = (Default) Not case-sensitive 1 = Case-sensitive
$b_MatchWholeWord | Optional: Specifies whether to have the find operation locate only entire words, not text that's part of a larger word. 0 = (Default) Match partial words 1 = Only match entire words
$b_MatchWildcards | Optional: Specifies whether to have $s_FindText be a special search operator. 0 = (Default) Not a special search operator 1 = Special search operator
$b_MatchSoundsLike | Optional: Specifies whether to have the find operation locate words that sound similar to $s_FindText. 0 = (Default) Do not find similar sounding words 1 = Find similar sounding words
$b_MatchAllWordForms | Optional: Specifies whether to have the find operation locate all forms of the find text (for example, "sit" locates "sitting" and "sat"). 0 = (Default) Do not match other word forms 1 = Match all word forms
$b_Forward | Optional: Specifies which direction to search. 0 = Search backward (toward the start of the document) 1 = (Default) Search forward (toward the end of the document)
$i_Wrap | Optional: Controls what happens if the search begins at a point other than the beginning of the document and the end of the document is reached (or vice versa if $b_Forward is set to 0). 0 = The find operation ends if the beginning or end of the search range is reached 1 = (Default) The find operation continues if the beginning or end of the search range is reached
$b_Format | Optional: Specifies whether to have the find operation locate formatting in addition to or instead of the find text. 0 = (Default) Do not locate formatting 1 = Locate formatting

Return Value

Success: | Returns 1
Failure: | Retuns 0 and sets @ERROR = 1
@Error: | 0 ($_WordStatus_Success) = No Error
 | 3 ($_WordStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_WordStatus_InvalidObjectType) = Invalid Object Type
 | 5 ($_WordStatus_InvalidValue) = Invalid Value
 | 7 ($_WordStatus_NoMatch) = No Match
@Extended: | Contains invalid parameter number

Remarks

You can search for special characters by specifying appropriate character codes. For example, "^p" corresponds to a paragraph mark and "^t" corresponds to a tab character.

You specify special characters and advanced search criteria just as you do for the Find argument. To specify a graphic object or other non-text item as the replacement, move the item to the Clipboard and specify "^c" for $s_ReplaceWith.

Related

None.

Example

; *******************************************************
; Example 1 - Create a word window, open a document, find "this",
; replace all occurrences with "THIS", quit without saving changes.
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate (@ScriptDir & "\Test.doc")
$oDoc = _WordDocGetCollection($oWordApp, 0)
$oFind = _WordDocFindReplace($oDoc, "this", "THIS")
If $oFind Then
MsgBox(0, "FindReplace", "Found and replaced.")
Else
MsgBox(0, "FindReplace", "Not Found")
EndIf
_WordQuit ($oWordApp, 0)


Function _WordDocGetCollection

Function Reference

_WordDocGetCollection

Returns a collection object containing all documents

#include <Word.au3>
_WordDocGetCollection ( ByRef $o_object [, $v_index = -1] )

Parameters

$o_object | Object variable of a Word.Application object
$v_index | Optional: Specifies whether to return a collection or indexed instance. -1 = (Default) Returns a collection 0 = Returns the Active Document The document name or index number to return (1 based)

Return Value

Success: | Returns an object collection of all documents, @EXTENDED = document count
Failure: | Retuns 0 and sets @ERROR = 1
@Error: | 0 ($_WordStatus_Success) = No Error
 | 3 ($_WordStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_WordStatus_InvalidObjectType) = Invalid Object Type
 | 5 ($_WordStatus_InvalidValue) = Invalid Value
 | 7 ($_WordStatus_NoMatch) = No Match
@Extended: | Contains invalid parameter number

Remarks

None.

Related

None.

Example

; *******************************************************
; Example 1 - Create a word window with a new blank document,
; add a second blank document, and get a collection of the documents.
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate ()
_WordDocAdd ($oWordApp)
$oDocuments = _WordDocGetCollection ($oWordApp)
MsgBox(0, "Document Count", @extended)
_WordQuit ($oWordApp)


Function _WordDocLinkGetCollection

Function Reference

_WordDocLinkGetCollection

Returns a collection object containing all links in the document

#include <Word.au3>
_WordDocLinkGetCollection ( ByRef $o_object [, $i_index = -1] )

Parameters

$o_object | Object variable of an Word.Application, document object
$i_index | Optional: specifies whether to return a collection or indexed instance Positive integer returns an indexed instance (1 based) -1 = (Default) returns a collection

Return Value

Success: | Returns an object collection of all links in the document, @EXTENDED = link count
Failure: | Retuns 0 and sets @ERROR = 1
@Error: | 0 ($_WordStatus_Success) = No Error
 | 3 ($_WordStatus_InvalidDataType) = Invalid Data Type
 | 5 ($_WordStatus_InvalidValue) = Invalid Value
 | 7 ($_WordStatus_NoMatch) = No Match
@Extended: | Contains invalid parameter number

Remarks

None.

Related

None.

Example

; *******************************************************
; Example 1 - Create a word window with a new blank document,
; add a link, then get a collection of links.
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate ()
$oDoc = _WordDocGetCollection ($oWordApp, 0)
_WordDocAddLink ($oDoc, "", "www.AutoIt3.com", "", "AutoIt" & @CRLF, "Link to AutoIt")
$oLinks = _WordDocLinkGetCollection ($oDoc)
MsgBox(0, "Link Count", @extended)


Function _WordDocOpen

Function Reference

_WordDocOpen

Opens an existing Microsoft Word Document

#include <Word.au3>
_WordDocOpen ( ByRef $o_object , $s_FilePath [, $b_ConfirmConversions = 0 [, $i_Format = 0 [, $b_ReadOnly = 0 [, $b_Revert = 0 [, $b_AddToRecentFiles = 0 [, $s_PasswordDocument = "" [, $s_WritePasswordDocument = ""]]]]]]] )

Parameters

$o_object | Object variable of a Word.Application object
$s_FilePath | Full path of the document to open (See Remarks)
$b_ConfirmConversions | Optional: Specifies whether to display the Convert File dialog box if the file isn't in Microsoft Word format. 0 = (Default) Do not display 1 = Display
$i_Format | Optional: The file converter to be used to open the document. 0 = (Default) The existing format 1 = Microsoft Word Document format 2 = Microsoft Word Template format 3 = Rich text format (RTF) 4 = Unencoded text format 5 = Unicode text format or Encoded text format 6 = Microsoft Word format that is backward compatible with earlier versions of Microsoft Word 7 = HTML format 8 = XML format
$b_ReadOnly | Optional: Specifies whether to open the document as read-only. Note: This argument doesn't override the read-only recommended setting on a saved document. 0 = (Default) Open as Read/Write 1 = Open as Read Only
$b_Revert | Optional: Controls what happens if $s_FilePath is an open document. 0 = (Default) Activate the open document 1 = Discard any unsaved changes to the open document and reopen the file
$b_AddToRecentFiles | Optional: Specifies whether to add the file name to the list of recently used files at the bottom of the File menu. 0 = (Default) Do not add 1 = Add
$s_PasswordDocument | Optional: The password for opening the document.
$s_WritePasswordDocument | Optional: The password for saving changes to the document.

Return Value

Success: | Returns an object variable pointing to a Word.Application, document object
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_WordStatus_Success) = No Error
 | 1 ($_WordStatus_GeneralError) = General Error
 | 3 ($_WordStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_WordStatus_InvalidObjectType) = Invalid Object Type
@Extended: | Contains invalid parameter number

Remarks

File will be created if it does not exist.

Related

_WordDocAdd, _WordDocClose, _WordDocSave, _WordDocSaveAs

Example

; *******************************************************
; Example 1 - Create an empty word window and open an existing document
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate ("")
$oDoc = _WordDocOpen ($oWordApp, @ScriptDir & "\Test.doc")


Function _WordDocPrint

Function Reference

_WordDocPrint

Prints all or part of the specified document.

#include <Word.au3>
_WordDocPrint ( ByRef $o_object [, $b_Background = 0 [, $i_Copies = 1 [, $i_Orientation = -1 [, $b_Collate = 1 [, $s_Printer = "" [, $i_Range = 0 [, $i_From = "" [, $i_To = "" [, $s_Pages = "" [, $i_PageType = 0 [, $i_Item = 0]]]]]]]]]]] )

Parameters

$o_object | Object variable of a Word.Application, document object
$b_Background | Optional: Specifies whether to have the script continue while Microsoft Word prints the document. (See Remarks) 0 = (Default) Wait for document to print 1 = Continue script without waiting
$i_Copies | Optional: The number of copies to be printed.
$i_Orientation | Optional: Sets the orientation of the page. -1 = (Default) Current document orientation 0 = Portrait 1 = Landscape
$b_Collate | Optional: Specifies whether to print all pages of the document before printing the next copy. 0 = Do not collate 1 = (Default) Collate
$s_Printer | Optional: Sets the name of the printer. (See Remarks)
$i_Range | Optional: Specifies the page range. 0 = (Default) The entire document 1 = The current selection 2 = The current page 3 = A specified range (must specify $i_From and $i_To) 4 = A specified range of pages (must specify $s_Pages)
$i_From | Optional: The starting page number when $i_Range is set to 3.
$i_To | Optional: The ending page number when $i_Range is set to 3.
$s_Pages | Optional: The page numbers and page ranges to be printed, separated by commas, when $i_Range is set to 4. For example, "2, 6-10" prints page 2 and pages 6 through 10.
$i_PageType | Optional: The type of pages to be printed. 0 = (Default) All pages 1 = Odd-numbered pages only 2 = Even-numbered pages only
$i_Item | Optional: The item to be printed. 0 = (Default) Current document content 1 = Properties in the current document 2 = Comments and Markup in the current document 3 = Styles in the current document 4 = Autotext entries in the current document 5 = Key assignments in the current document 6 = An envelope 7 = Current document content including markup

Return Value

Success: | Returns 1
Failure: | Retuns 0 and sets @ERROR = 1
@Error: | 0 ($_WordStatus_Success) = No Error
 | 1 ($_WordStatus_GeneralError) = General Error
 | 2 ($_WordStatus_ComError) = Com Error
 | 3 ($_WordStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_WordStatus_InvalidObjectType) = Invalid Object Type
 | 5 ($_WordStatus_InvalidValue) = Invalid Value
@Extended: | Contains invalid parameter number

Remarks

Specifying $b_Background does NOT pause the script until the document is finished printing, it only pauses until Microsoft Word finishes sending the document to the printer. If you execute a background print then immediately execute a _WordQuit() the document will not have time to print.

To specify a network printer it needs to be in this format "\\Server\Printer".

Related

None.

Example

; *******************************************************
; Example 1 - Create a word window, open a document, set the text,
; print with defaults, and quit without saving changes.
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate (@ScriptDir & "\Test.doc")
$oDoc = _WordDocGetCollection ($oWordApp, 0)
$oDoc.Range.Text = "This is some text to print."
_WordDocPrint ($oDoc)
_WordQuit ($oWordApp, 0)

; *******************************************************
; Example 2 - Create a word window, open a document, set the text,
; print using landscape, and quit without saving changes.
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate (@ScriptDir & "\Test.doc")
$oDoc = _WordDocGetCollection ($oWordApp, 0)
$oDoc.Range.Text = "This is some text to print."
_WordDocPrint ($oDoc, 0, 1, 1)
_WordQuit ($oWordApp, 0)

; *******************************************************
; Example 3 - Create a word window, open a document, set the text,
; print to a printer named "My Printer", and quit without saving changes.
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate (@ScriptDir & "\Test.doc")
$oDoc = _WordDocGetCollection ($oWordApp, 0)
$oDoc.Range.Text = "This is some text to print."
_WordDocPrint ($oDoc, 0, 1, 0, 1, "My Printer")
_WordQuit ($oWordApp, 0)


Function _WordDocPropertyGet

Function Reference

_WordDocPropertyGet

Returns a select property of the Word Document.

#include <Word.au3>
_WordDocPropertyGet ( ByRef $o_object, $v_property )

Parameters

$o_object | Object variable of a Word.Application, document object
$v_property | Property selection (see remarks)

Return Value

Success: | Value of selected Property
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_WordStatus_Success) = No Error
 | 1 ($_WordStatus_GeneralError) = General Error
 | 2 ($_WordStatus_ComError) = Com Error
 | 3 ($_WordStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_WordStatus_InvalidObjectType) = Invalid Object Type
 | 5 ($_WordStatus_InvalidValue) = Invalid Value
@Extended: | Contains invalid parameter number

Remarks

You may use either the index or name as the property selection.

The following tables provide a description of each property available for use.

Word Document Properties

Property Index/Name | Description
(1) "title" | Title.
(2) "subject" | Subject.
(3) "author" | Author.
(4) "keywords" | Keywords.
(5) "comments" | Comments.
(6) "template" | Template name.
(7) "last author" | Last Author.
(8) "revision number" | Revision number.
(9) "application name" | Name of application.
(10) "last print date" | Time last printed.
(11) "creation date" | Time created.
(12) "last save time" | Time last saved.
(13) "total editing time" | Number of edits to VBA project.
(14) "pages" | Page count.
(15) "words" | Word count.
(16) "characters" | Character count.
(17) "security" | Security setting.
(18) "category" | Category.
(19) "" | Not supported.
(20) "manager" | Manager.
(21) "company" | Company.
(22) "bytes" | Byte count.
(23) "lines" | Line count.
(24) "paragraphs" | Paragraph count.
(25-28) "" | Not Supported.
(29) "hyperlink base" | When a relative link is based on a path you specify (the first part of the path that is shared by the file containing the hyperlink and the destination file), that path is the hyperlink base.
(30) "characters (with spaces)" | Character count with spaces.

Related

_WordDocPropertySet

Example

; *******************************************************
; Example 1 - Create a word window, open a document,
; then read all available document properties by index
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate (@ScriptDir & "\Test.doc")
$oDoc = _WordDocGetCollection ($oWordApp, 0)
For $i = 1 To 30
ConsoleWrite("Property Index " & $i & " - " & _WordDocPropertyGet ($oDoc, $i) & @CR)
Next

; *******************************************************
; Example 2 - Create a word window, open a document,
; then read the title, subject, and author properties by name.
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate (@ScriptDir & "\Test.doc")
$oDoc = _WordDocGetCollection ($oWordApp, 0)
ConsoleWrite("Title - " & _WordDocPropertyGet ($oDoc, "Title") & @CR)
ConsoleWrite("Subject - " & _WordDocPropertyGet ($oDoc, "Subject") & @CR)
ConsoleWrite("Author - " & _WordDocPropertyGet ($oDoc, "Author") & @CR)


Function _WordDocPropertySet

Function Reference

_WordDocPropertySet

Set a select property of the Word Document

#include <Word.au3>
_WordDocPropertySet ( ByRef $o_object, $v_property, $v_newvalue )

Parameters

$o_object | Object variable of a Word.Application, document object
$v_property | Property selection (see remarks)
$v_newvalue | The new value to be set into the Word Document Property

Return Value

Success: | Returns 1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_WordStatus_Success) = No Error
 | 1 ($_WordStatus_GeneralError) = General Error
 | 2 ($_WordStatus_ComError) = Com Error
 | 3 ($_WordStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_WordStatus_InvalidObjectType) = Invalid Object Type
 | 5 ($_WordStatus_InvalidValue) = Invalid Value
@Extended: | Contains invalid parameter number

Remarks

You may use either the index or name as the property selection.

The following tables provide a description of each property available for use.

Word Document Properties

Property Index/Name | Description
(1) "title" | Title.
(2) "subject" | Subject.
(3) "author" | Author.
(4) "keywords" | Keywords.
(5) "comments" | Comments.
(6) "template" | Template name.
(9) "application name" | Name of application.
(18) "category" | Category.
(20) "manager" | Manager.
(21) "company" | Company.
(29) "hyperlink base" | When a relative link is based on a path you specify (the first part of the path that is shared by the file containing the hyperlink and the destination file), that path is the hyperlink base.

Related

_WordDocPropertyGet

Example

; *******************************************************
; Example 1 - Create a word window, open a document,
; then set the title, subject, and author properties.
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate (@ScriptDir & "\Test.doc")
$oDoc = _WordDocGetCollection ($oWordApp, 0)
_WordDocPropertySet ($oDoc, "Title", "Test Title")
_WordDocPropertySet ($oDoc, "Subject", "Test Subject")
_WordDocPropertySet ($oDoc, "Author", "Test Author")


Function _WordDocSave

Function Reference

_WordDocSave

Saves a previously opened document

#include <Word.au3>
_WordDocSave ( $o_object )

Parameters

$o_object Object variable of a Word.Application, document object

Return Value

Success: | Returns 1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_WordStatus_Success) = No Error
 | 1 ($_WordStatus_GeneralError) = General Error
 | 3 ($_WordStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_WordStatus_InvalidObjectType) = Invalid Object Type
@Extended: | Contains invalid parameter number

Remarks

If a document hasn't been saved before, the Save As dialog box prompts the user for a file name.

Related

_WordDocAdd, _WordDocClose, _WordDocOpen, _WordDocSaveAs

Example

; *******************************************************
; Example 1 - Open an existing word document, append some text,
; save and quit.
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate (@ScriptDir & "\Test.doc")
$oDoc = _WordDocGetCollection ($oWordApp, 0)
$oDoc.Range.insertAfter ("This is some text to insert.")
_WordDocSave ($oDoc)
_WordQuit ($oWordApp)


Function _WordDocSaveAs

Function Reference

_WordDocSaveAs

Saves the specified document with a new name or format.

#include <Word.au3>
_WordDocSaveAs ( ByRef $o_object [, $s_FilePath = "" [, $i_Format = 0 [, $b_ReadOnlyRecommended = 0 [, $b_AddToRecentFiles = 0 [, $b_LockComments = 0 [, $s_Password = "" [, $s_WritePassword = ""]]]]]]] )

Parameters

$o_object | Object variable of a Word.Application, document object
$s_FilePath | Optional: The full file path for saving the document. (See Remarks) "" = (Default) If the document has never been saved, the default name is used (for example, Document1.doc)
$i_Format | Optional: The format in which the document is saved. 0 = (Default) Microsoft Word format 1 = Microsoft Word template format 2 = Microsoft Windows text format 3 = Microsoft Windows text format with line breaks preserved 4 = Microsoft DOS text format 5 = Microsoft DOS text with line breaks preserved 6 = Rich text format (RTF) 7 = Unicode text format or Encoded text format 8 = Standard HTML format 9 = Web archive format 10 = Filtered HTML format 11 = Extensible Markup Language (XML) format
$b_ReadOnlyRecommended | Optional: Specifies whether to have Microsoft Word suggest read-only status whenever the document is opened. 0 = (Default) Do not suggest read only 1 = Suggest read only
$b_AddToRecentFiles | Optional: Specifies whether to add the file name to the list of recently used files at the bottom of the File menu. 0 = (Default) Do not add 1 = Add
$b_LockComments | Optional: Specifies whether to lock the document for comments. 0 = (Default) Do not lock for comments 1 = Lock for comments
$s_Password | Optional: A password string for opening the document. (See Remarks)
$s_WritePassword | Optional: A password string for saving changes to the document. (See Remarks)

Return Value

Success: | Returns 1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_WordStatus_Success) = No Error
 | 1 ($_WordStatus_GeneralError) = General Error
 | 3 ($_WordStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_WordStatus_InvalidObjectType) = Invalid Object Type
@Extended: | Contains invalid parameter number

Remarks

If a document with the specified file name already exists, the document is overwritten without the user being prompted first.

Avoid using hard-coded passwords in your applications. If a password is required in a procedure, request the password from the user, store it in a variable, and then use the variable in your code.

Related

_WordDocAdd, _WordDocClose, _WordDocOpen, _WordDocSave

Example

; *******************************************************
; Example 1 - Create a word window with a new blank document, add some text,
; execute a saveas operation, then quit.
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate ()
$oDoc = _WordDocGetCollection ($oWordApp, 0)
$oDoc.Range.Text = "This is some text to insert."
_WordDocSaveAs ($oDoc, @ScriptDir & "\Test.doc")
_WordQuit ($oWordApp)


Function _WordErrorHandlerDeRegister

Function Reference

_WordErrorHandlerDeRegister

Disable a registered user COM error handler

#include <Word.au3>
_WordErrorHandlerDeRegister ( )

Parameters

None.

Return Value

Success: | Returns 1
Failure: | None

Remarks

See remarks for _WordErrorHandlerRegister.

Related

_WordErrorHandlerRegister

Example

; *******************************************************
; Example 1 - Register and later deregister a custom error handler
; *******************************************************
;
#include <Word.au3>
; Register a customer error handler
_WordErrorHandlerRegister ("MyErrFunc")
; Do something
; Deregister the customer error handler
_WordErrorHandlerDeregister ()
; Do something else

Exit

Func MyErrFunc()
$HexNumber = Hex($oWordErrorHandler.number, 8)
MsgBox(0, "", "We intercepted a COM Error !" & @CRLF & _
"Number is: " & $HexNumber & @CRLF & _
"Windescription is: " & $oWordErrorHandler.windescription)
SetError(1) ; something to check for when this function returns
EndFunc ;==>MyErrFunc


Function _WordErrorHandlerRegister

Function Reference

_WordErrorHandlerRegister

Register and enable a user COM error handler

#include <Word.au3>
_WordErrorHandlerRegister ( [$s_functionName = "__WordInternalErrorHandler"] )

Parameters

$s_functionName Optional: String variable with the name of a user-defined COM error handler, defaults to the internal COM error handler in this UDF

Return Value

Success: | Returns 1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_WordStatus_Success) = No Error
 | 1 ($_WordStatus_GeneralError) = General Error
@Extended: | Contains invalid parameter number

Remarks

Important: When using your own error handler, the Error Object variable used MUST be named $oWordErrorHandler (see example).

AutoIt has the ability to trap COM errors and pass then through a custom error handler using the ObjEvent function. There is a problem with this for UDF writers however because only a single COM error handler can be in use at a time. For the UDF to use a COM error handler it must first deregister the user error handler, install its own and then put the user handler back in place. Unfortunately, by default, the UDF has no way to access the handle of the user error handler.

Using this routine you can register your COM error handler in a way that Word.au3 can gracefully remove and reinstate it when it needs to. You may either point to your own custom error handler or you may use the one developed for Word.au3 (the default). Using the default Word.au3 error handler you will also get some nice diagnostic information written to the console and some global variables that contain information about the trapped errors.

If you instantiate your own COM error handler without using this routine Word.au3 will not be able to trap some COM errors and you may experience some abrupt script terminations as a result.

Related

_WordErrorHandlerDeRegister

Example

; *******************************************************
; Example 1 - Register and later deregister a custom and the default Word.au3 error handler
; *******************************************************
;
#include <Word.au3>
; Register a customer error handler
_WordErrorHandlerRegister ("MyErrFunc")
; Do something
; Deregister the customer error handler
_WordErrorHandlerDeregister ()
; Do something else
; Register the default IE.au3 COM Error Handler
_WordErrorHandlerRegister ()
; Do more work

Exit

Func MyErrFunc()
; Important: the error object variable MUST be named $oWordErrorHandler
$ErrorScriptline = $oWordErrorHandler.scriptline
$ErrorNumber = $oWordErrorHandler.number
$ErrorNumberHex = Hex($oWordErrorHandler.number, 8)
$ErrorDescription = StringStripWS($oWordErrorHandler.description, 2)
$ErrorWinDescription = StringStripWS($oWordErrorHandler.WinDescription, 2)
$ErrorSource = $oWordErrorHandler.Source
$ErrorHelpFile = $oWordErrorHandler.HelpFile
$ErrorHelpContext = $oWordErrorHandler.HelpContext
$ErrorLastDllError = $oWordErrorHandler.LastDllError
$ErrorOutput = ""
$ErrorOutput &= "--> COM Error Encountered in " & @ScriptName & @CR
$ErrorOutput &= "----> $ErrorScriptline = " & $ErrorScriptline & @CR
$ErrorOutput &= "----> $ErrorNumberHex = " & $ErrorNumberHex & @CR
$ErrorOutput &= "----> $ErrorNumber = " & $ErrorNumber & @CR
$ErrorOutput &= "----> $ErrorWinDescription = " & $ErrorWinDescription & @CR
$ErrorOutput &= "----> $ErrorDescription = " & $ErrorDescription & @CR
$ErrorOutput &= "----> $ErrorSource = " & $ErrorSource & @CR
$ErrorOutput &= "----> $ErrorHelpFile = " & $ErrorHelpFile & @CR
$ErrorOutput &= "----> $ErrorHelpContext = " & $ErrorHelpContext & @CR
$ErrorOutput &= "----> $ErrorLastDllError = " & $ErrorLastDllError
MsgBox(0, "COM Error", $ErrorOutput)
SetError(1)
Return
EndFunc ;==>MyErrFunc


Function _WordErrorNotify

Function Reference

_WordErrorNotify

Specifies whether Word.au3 automatically notifies of Warnings and Errors (to the console)

#include <Word.au3>
_WordErrorNotify ( [$f_notify = -1] )

Parameters

$f_notify Optional: specifies whether notification should be on or off
-1 = (Default) return current setting
True = Turn On
False = Turn Off

Return Value

Success: | If $f_notify = -1, returns the current notification setting, else returns 1
Failure: | Returns 0

Remarks

Word.au3 writes diagnostic information, warnings and errors to the console by default. This information can readily be seen when using the SciTe editor to run your scripts.

This function allows you to turn this functionality on or off.

Related

None.

Example

; *******************************************************
; Example 1 - Check the current status of _WordErrorNotify, turn it off if on, on if off
; *******************************************************
;
#include <Word.au3>
If _WordErrorNotify () Then
MsgBox(0, "_WordErrorNotify Status", "Notification is ON, turning it OFF")
_WordErrorNotify (1)
Else
MsgBox(0, "_WordErrorNotify Status", "Notification is OFF, turning it ON")
_WordErrorNotify (0)
EndIf


Function _WordMacroRun

Function Reference

_WordMacroRun

Runs a Visual Basic macro

#include <Word.au3>
_WordMacroRun ( $o_object, $s_MacroName [, $v_Arg1, [, ... [, $v_Arg30]]] )

Parameters

$o_object | Object variable of a Word.Application object
$s_MacroName | The name of the macro. Can be any combination of template, module, and macro name. (See Remarks)
$v_Arg1 | Optional: The first parameter to pass to the macro
... | ...
$v_Arg30 | Optional: The thirtieth parameter to pass to the macro

Return Value

Success: | Returns 1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_WordStatus_Success) = No Error
 | 1 ($_WordStatus_GeneralError) = General Error
 | 2 ($_WordStatus_ComError) = Com Error
 | 3 ($_WordStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_WordStatus_InvalidObjectType) = Invalid Object Type
@Extended: | Contains invalid parameter number

Remarks

If you specify the document name, your code can only run macros in documents related to the current context — not just any macro in any document.

Related

None.

Example

; *******************************************************
; Example 1 - Create a word window, open a document,
; run a macro named "My Macro" with one
; argument "Test", quit without saving changes.
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate (@ScriptDir & "\Test.doc")
_WordMacroRun ($oWordApp, "My Macro", "Test")
_WordQuit ($oWordApp, 0)


Function _WordPropertyGet

Function Reference

_WordPropertyGet

Returns a select property of the Word Application.

#include <Word.au3>
_WordPropertyGet ( ByRef $o_object, $s_property )

Parameters

$o_object | Object variable of a Word.Application
$s_property | Property selection (see remarks)

Return Value

Success: | Value of selected Property
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_WordStatus_Success) = No Error
 | 3 ($_WordStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_WordStatus_InvalidObjectType) = Invalid Object Type
 | 5 ($_WordStatus_InvalidValue) = Invalid Value
@Extended: | Contains invalid parameter number

Remarks

Further information can be found at MSDN.

The following tables provide a description of each property available for use.

Word Application Properties

Property | Description
"activeprinter" | Returns the name of the active printer.
"capslock" | Returns a Boolean value indicating whether the CAPS LOCK key is turned on.
"screentips" | Returns a Boolean value indicating whether comments, footnotes, endnotes, and hyperlinks are displayed as tips.
"scrollbars" | Returns a Boolean value indicating whether Word displays a scroll bar in at least one document window.
"statusbar" | Returns a Boolean value indicating whether the status bar is displayed.
"height" | Returns the height of the active document window.
"language" | Returns an MsoLanguageID constant that represents the language selected for the Microsoft Word user interface.
"left" | Returns an Integer that represents the horizontal position of the active document.
"numlock" | Returns the state of the NUM LOCK key. Returns True if the keys on the numeric keypad insert numbers, and False if the keys move the insertion point.
"path" | Returns the disk or Web path to the specified object.
"screenupdating" | Returns a Boolean value indicating whether screen updating is turned on.
"startuppath" | Returns the complete path of the startup folder, excluding the final separator.
"top" | Returns the vertical position of the active document, in points.
"version" | Returns the Microsoft Word version number.
"visible" | Returns a Boolean value indicating whether the specified object is visible.
"width" | Returns the width of the specified object, in points.
"windowstate" | Returns the state of the specified document window or task window.

Related

_WordPropertySet

Example

; *******************************************************
; Example 1 - Create a word window, open a document, check to see if the
; statusbar is visible, if it is turn it off, if it isn't turn it on.
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate (@ScriptDir & "\Test.doc")
If _WordPropertyGet ($oWordApp, "statusbar") Then
MsgBox(0, "StatusBar Status", "StatusBar Visible, turning it off.")
_WordPropertySet ($oWordApp, "statusbar", False)
Else
MsgBox(0, "StatusBar Status", "StatusBar Invisible, turning it on.")
_WordPropertySet ($oWordApp, "statusbar", True)
EndIf


Function _WordPropertySet

Function Reference

_WordPropertySet

Set a select property of the Word Application.

#include <Word.au3>
_WordPropertySet ( ByRef $o_object, $s_property, $v_newvalue )

Parameters

$o_object | Object variable of a Word.Application
$s_property | Property selection (see remarks)
$newvalue | The new value to be set into the Word Application Property

Return Value

Success: | Returns 1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_WordStatus_Success) = No Error
 | 3 ($_WordStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_WordStatus_InvalidObjectType) = Invalid Object Type
 | 5 ($_WordStatus_InvalidValue) = Invalid Value
@Extended: | Contains invalid parameter number

Remarks

Further information can be found at MSDN.

The following tables provide a description of each property available for use.

Word Application Properties

Property | Description
"activeprinter" | Specifies the name of the active printer.
"screentips" | Specifies a Boolean value indicating whether comments, footnotes, endnotes, and hyperlinks are displayed as tips.
"scrollbars" | Specifies a Boolean value indicating whether Word displays a scroll bar in at least one document window.
"statusbar" | Specifies a Boolean value indicating whether the status bar is displayed.
"height" | Specifies the height of the active document window.
"left" | Specifies an Integer that represents the horizontal position of the active document.
"screenupdating" | Specifies a Boolean value indicating whether screen updating is turned on.
"startuppath" | Specifies the complete path of the startup folder.
"top" | Specifies the vertical position of the active document, in points.
"visible" | Specifies a Boolean value indicating whether the specified object is visible.
"width" | Specifies the width of the specified object, in points.
"windowstate" | Specifies the state of the specified document window or task window.

Related

_WordPropertyGet

Example

; *******************************************************
; Example 1 - Create a word window, open a document,
; hide the window, then make it visible again.
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate (@ScriptDir & "\Test.doc")
Sleep(2000)
_WordPropertySet ($oWordApp, "visible", False)
Sleep(2000)
_WordPropertySet ($oWordApp, "visible", True)


Function _WordQuit

Function Reference

_WordQuit

Close the window and remove the object reference to it

#include <Word.au3>
_WordQuit( ByRef $o_object [, $i_SaveChanges = -2 [, $i_OriginalFormat = 1 [, $b_RouteDocument = 0]]] )

Parameters

$o_object | Object variable of a Word.Application
$i_SaveChanges | Optional: specifies the save action for the document 0 = Do not save changes -1 = Save changes -2 = (Default) Prompt to save changes
$i_OriginalFormat | Optional: specifies the save format for the document 0 = Word Document 1 = (Default) Original Document Format 2 = Prompt User
$b_RouteDocument | Optional: specifies whether to route the document to the next recipient 0 = (Default) do not route 1 = route to next recipient

Return Value

Success: | Returns 1
Failure: | Returns 0 and sets @ERROR
@Error: | 0 ($_WordStatus_Success) = No Error
 | 1 ($_WordStatus_GeneralError) = General Error
 | 3 ($_WordStatus_InvalidDataType) = Invalid Data Type
 | 4 ($_WordStatus_InvalidObjectType) = Invalid Object Type
@Extended: | Contains invalid parameter number

Remarks

None.

Related

_WordCreate, _WordAttach

Example

; *******************************************************
; Example 1 - Create an invisible word window, open a
; document, retrieve some information and Quit
; *******************************************************
;
#include <Word.au3>
$oWordApp = _WordCreate (@ScriptDir & "\Test.doc", 0, 0)
; Display the text within the document
$sText = $oWordApp.ActiveDocument.Range.Text
MsgBox(0, "Document Text", $sText)
_WordQuit ($oWordApp)


8/13/2007:
   - Update: _IE.au3 version 2.3.1  (DaleHohm)

7/9/2007:
   - Fixed: _SoundSeek now works with filenames. (RazerM)
   - Fixed: _Sound functions work with filenames that have spaces. (RazerM)
   - fixed a little bug in the version comparison procedure and updated the included SQLite dll to 3.4.0. (Piccaso)
   - Change _ReplaceStringInFile() to update the original file in stead of replacing it. (JdeB)

7/4/2007:
   - Added _DateToMonth UDF to Date.au3. (exodius)
   - Added Optional: Handle of owner window to _ChooseColor andf ChooseFont. (gafrost)

3.2.3.15
   - Added _IEGetObjByID to IE.au3 (DaleHohm)
   - Fixed _IEPropertyGet() directives appversion and appminorversion (Dale Hohm)
   - Fixed _IELoadWait to trap ClientDisconnected Com errors (DaleHohm)
   - Fixed and enhanced web links in _IE_Introduction('basic') (DaleHohm)
   - Several updates to IE.au3 documentation and examples (DaleHohm)
   - Total rewrite of _ArrayDisplay with more options. (randallc)

3.2.3.13 (5/2/2007)
   - Several GUI Include file changed due to removal of Struct-EndStruct for the time being. (gafrost)
   - Added helper UDF _GetClassName() to Misc.au3. (gafrost)

3.2.3.7 (4/24/2007)
   - Several GUI Include file fixed of reportd issues for UNICODE support. (gafrost)
   - Added Word.au3 containing the well known Word UDF's... thanks Bob. (Big_Daddy)
   - Updated Memory.au3 that allows UDFs to live in harmony the ones from Auto3Lib. (gafrost/paulIA)

3.2.3.2 (29 March 2007)
   - Fixed _DateIsValid function to properly check the time component.

3.2.1.15 (16 December 2006)
   - Updated GUIList.au3/GUIListView/GUIStatusBar functions to free memory if there is an error. (gafrost)
   - Updated GUIEdit.au3 Condensed code utilizing _SendMessage. (gafrost)
   - Added _GUICtrlEditGetLine function to GUIEdit.au3. (gafrost)
   - Added EditConstants.au3. (gafrost)
   - Update: rewrite for _PathFull() that adds some functionality,
             fixing some bugs and incresaing performance tremendously. (tittoproject,Valik)
   - Updated IE.au3 v2.1.0 see header of the include file

3.2.1.14 (23 November 2006)
   - Added _TCPIpToName to INET.AU3. (piccaso)
   - Updated _ArraySearch() to Start/End/Case and Partial search.(gcriaco)
   - Updated/Cleaned up/Consolidated code in the GuiListView.au3 now works with System Controls. (gafrost)
   - Updated/Cleaned up/Consolidated code in GuiList.au3 (gafrost)
   - Updated/Cleaned up/Consolidated code in GuiStatusBar.au3 and updated Examples.(gafrost)
   - Added Memory.au3 which is used in both the above includes (gafrost)
   - _GUICtrlListViewGetItemText.au3 example is now 2 examples in 1 (gafrost)

3.2.1.12 (28 October 2006)
   - Added __StringAddComma and _StringBetween to String.au3. (SmOke_N)
   - Fixed _ChooseFont. (gafrost)
   - Fixed _GUICtrlStatusBarCreateProgress ;It doesn't work on simple mode statusbar
   - Fixed _FileListToArray doc example. (Thanks Frank60)

3.2.1.10 (13 October 2006)
   - Added _GUICtrlListViewEnsureVisible. (gafrost)
   - Added _GUICtrlStatusBarCreateProgress. (gafrost)
   - Updated _GUICtrlTreeViewSetState. (gafrost)
   - Fixed _SendMessage Doc for Helpfile. (jdeb)
   - Added _GUICtrlListViewFindItem. (gafrost)

3.2.1.9 (8 October 2006)
   - Added _SQLlite UDFS in SQLite.au3. (piccaso)
   - Added _SendMessage to Misc.au3. (Valik/gafrost)

3.2.1.5 (22 September 2006)
   - Added 2 UDF's to GUIStatusBar.au3. (gafrost)
   - Several updates to GUIStatusBar.au3. (gafrost)
   - Several updates to Sound.au3.  (RazerM)

3.2.1.2 (7 September 2006)
   - Added 2 UDF's to GUIStatusBar.au3. (gafrost)
   - Added GuiIPAddress.au3 to Include directory. (gafrost)
   - Added Sound.au3 with several sound UDFs to Include directory. (RazerM)
   - removed the version numbers from the include files.

1.66 (17 July 2006)
   - Changed _FilesListToArray(): Added @error 4 meaning no files found. (gafrost)
   - Gui Function general cleanup (gafrost)
   - Changed: Constants seperated out into seperate files. (Valik)
   - Changed: GUIConstants.au3 is now a stub including pretty much everything (Use GUIConstantsEx.au3 and the
     other *Constants.au3 files for more granularity). (Valik)
   - Updated several Helpfile pages for ie.au3. (Big_Daddy)
   - Updated several functions in visa.au3. (Angel)
      - Fixed : _viPrintf and _viExecCommand would not work with certain GPIB cards (such as USB-GPIB cards).
        Changed use of the VISA command "viWrite" method to be more generic (thanks John Herrington for the tip).
      - Added : Additional OPTIONAL parameter for _viPrintf and _viExecComand. Controls command send mode
        and terminator. Default value is "Use @LF terminator".
      - Updated : _viPrintf and _ViExecCommand append an @LF to every VISA command by default.
        This can be changed by means of a new optional parameter.
      - Updated : _viPrintf and _ViExecCommand do not "protect" for escape characters anymore by default.
        That causes problems with some GPIB cards. It is possible to go back to the original behaviour
        by setting the new optional parameter $s_mode to "str".

1.65 (6 July 2006)
   - Added IE.au3 with all its well known Functions. Big Thanks to DaleHohm and Big_Daddy. (DaleHohm,Big_Daddy)
   - Changed _InetSmtpMail(), change initial connection logic.  (Neil)
   - Fixed _TicksToTime() StringIsInt() problem. (JdeB)
   - Fixed Bug in _GUICtrlListViewGetItemText on return if a subitem is empty. (gafrost)

1.64 (27 June 2006)
   - Updated _GUICtrlListViewGetItemText: removed $v_ret variable to avoid au3check errors. (gafrost)
   - Updated _GUIListView: Some bugfixes and Helpfile correction. (gafrost)
   - Updated _GUIListView: Found a way I can live with the -1 being in the _GUICtrlListViewGetItemText
     and _GUICtrlListViewGetItemTextArray for using selected index in the function calls. (gafrost)

1.63 (19 June 2006)
   - Updated _DateTimeFormat() to use a default template when registry entries are missing
     Like in Win9x/WinME for SLongDate.
   - GuiListView updated .This update will possible break scripts. (gafrost)
      Replaced ControlListView calls (will no longer need window title/text in params).
      Functions updated to reflect new params.
      Examples updated for consistancy.
      Templates updated as needed.
   - _ArrayBinarySearch: (JdeB)
      removed check for more than 1 entry to allow the use of this UDF on arrays with one entry.

1.62 (2 June 2006)
   - Fixed _ClipPutFile() example include statement. (RazerM)
   - Doc Fixes:
     _GUICtrlListViewEnsureVisible. (gafrost)
     _FileReadToArray. (CyberSlug)
   _ Fixed _Now() which was returning "tt" at the end (JdeB)

1.61 (23 May 2006)
   - Fixed _GuiCtrlListViewSort() avoiding insert/removal of spaces. (gafrost)
   - Changed test in _DateIsValid() test from <1900 to <1000 to allow
     a startdate of 1600 used for UTC calculations. (JdeB)
   - Changed _GUICtrlListViewSort. (JPM)
   - Added _ClipPutFile() to misc.au3. (Piccaso)
   - Updated _GUICtrlListViewSetItemSelState, added an optional focus state parameter. (gafrost)

1.60 (28 April 2006)
   - Updated _GuiCtrlStatusBarResize example. (gafrost)
   - Added 2 variables to GuiStatusBar.au3. (gafrost)
   - Fixed typo in _ArraySort. (Knight)

1.59 (20 April 2006)
   - Updated _ProcessGetPriority to use 0x0400. (Valik)
   - Added _GUICtrlEditSetRECT to GuiEdit.au3. (gafrost)
   - Updated Email addresses in UDF's to avoid retrieval by search engines. (JPM)

1.58 (6 April 2006
   - updated _ProcessGetPriority() to accept either a name or PID argument. (Valik)
   - Fixed bug in _FileWriteLine() insert mode not inserting new line. (sasdad)

1.57 (19 March 2006
   - Updated : GUICtrlTreeView
     * Changed _GUICtrlTreeViewExpand (Parent GUI handle no longer needed) (Holger)
     * Renamed _GUICtrlTreeViewItemGetTree to _GUICtrlTreeViewGetTree !!! (Holger)
     * Added _GUICtrlTreeViewGetState (Holger)
     * Added _GUICtrlTreeViewGetText (Holger)
     * Added _GUICtrlTreeViewInsertItem (Holger)
     * Added _GUICtrlTreeViewSetIcon (Holger)
     * Added _GUICtrlTreeViewSetState (Holger)
     * Added _GUICtrlTreeViewSetText (Holger)

1.56 (15 March 2006)
   - Updated _GUICtrlListViewSort Helpfile example. (gafrost)
   - Updated _GUICtrlCombo examples updated to proper height. (gafrost)
   - Updated GUIComboau3. Added #include <GUIConstants.au3>. (andyswarbs)

1.55 (2 March 2006)
   - Updated INetSmtpMail(),allow the "EHLO" to be send. (JPM)
   - Added Attribute to _GUICtrlComboAddDir, _GUICtrlListAddDir. (gafrost)
   - Added _GUICtrlListViewSetColumnHeaderText() to GuiListView. (gafrost)

1.54 (23 February 2006)
   - Added _GuiCtrlEditFind to GUIEDIT.AU3: - Find/Replace text in an Edit control. (gafrost)
   - Added _FileWriteToLine to FILE.AU3: Writes text to a specific line in a file. (cdkid)

1.53 (16 February 2006)
   - Fixed _GuiCtrlListViewDeleteItem: Listview items can't be deleted after sorting. (gafrost)

1.52 (8 February 2006)
   - Fixed typo in _ArraySearch Helpfile. (theguy0000)
   - Fixed _ArraySort Local $t decleration. (gafrost)
   - Fixed _GUICtrlComboAutoComplete() move Variable definitions to the stat of the function. (gafrost)
   - Fixed _GuiCtrlStatusBarCreate : corrected variable declarations in the function. (gafrost)

1.51 (3 February 2006)
   - Changed _InetGetSource to return "" when error occurs.  (erebus)
   - Changed Dim to Local in GuiStatusBar.au3. (Jdeb)
   - Change _GuiCtrlStatusBarSetIcon that will allow removing the icon from normal status bar. (gafrost)
   - Added version at the top of each UDF file.

1.50 (20 January 2006)
   - Added _GUIStatusBar.au3 UDF's. (gafrost, rysiora, JdeB, tonedef, eltorro)
   - Added _GUICtrlComboGetList to GUICombo.au3 which retrieves all items in a combobox (Valik)
   - Fixed _INetSmtpMail() paramater variable name. (JPM)

1.49 (17 January 2006)
   - Fixed bug in _ArrayPush() when Direction 1 is specified. (AnnA)
   - Helpfile _ArraySearch example corrected. (Valuater)
   - Removed obsolete parameters from _GUICtrlTreeViewSelectItem(), Scripts need updating! (JdeB)
   - Fixed : _INetSmtpMail() (by JPM). (Thanks Wooltown, MikeOsdx)
   - Updated all UDFs to get rid of any Errors from Au3Check v 1.50 will All checks enabled.
   - Updated _ArrayDisplay() added Const to Byref of the first parameter. (Valik)
   - Fixed bug in _PathFull when using root of a drive. (Valik)

1.48 (7 January 2006)
   - Fixed : _PathFull() 2 bugs. (by Valik)
   - Fixed : _INetSmtpMail() @error 5 (by JPM). (Thanks Wooltown, MikeOsdx)
   - Fixed : _StringEncrypt error return. (Thanks JerryD)

1.47 (30 December 2005)
   - Fixed _DateTimeFormat() to return LongTime notation for $sType=0 as specified in the Helpfile. (JdeB)
   - Made Subject and Body optional in _InetSmtpMail().  (PartyPooper)

1.46 (21 December 2005)
   - Fixed doc for _FileReadToArray(). (LxP)
   - Fixed doc and Example for _ArraySearch. (Knight)
   - Fixed _ArraySearch return value in case not found to -1. (SolidSnake)
   - Added _InetSmtpMail to Inet.au3. (Walkabout)

1.45 (2 December 2005)
   - Fixed _PathSplit(). Changed Dim $array[5] to Local $array[5]. (LxP)
   - Updated _InetGetSource(), Remove stripping last character in return string. (w0uter)
   - Fixed return value in _GUICtrlTreeViewDeleteItem when item id passed in. (gafrost)
   - Updated GUI UDFs: Update Includes and Templates for use with external controls
     Meaning controlID for autoit control, control hWnd for external control
     Also replace all Dim statements with Local. (gafrost)

1.44 (25 November 2005)
   - Fixed _ReplaceStringInFile to avoid adding CRLF when missing at the EOF. (JdeB)
   - Added _ProcessGetName to Process.au3. (Erifash)

1.43 (18 November 2005)
   - Fixed _DateAdd() Typo's in helpfile. (Gene)
   - Updated _INetMail() with new logic to support environment variables. (JPM)
   - Updated _GUICtrlListViewDeleteItemsSelected() with Test for Array. (CatchFish)
   - Added a Constant to GUIList.au3 and changed all examples. (gafrost)

1.42 (2 November 2005)
   - Updated _ArrayToString documentation, changed parameter order. (Josbe)
   - Updated _FileList2Array: removed checking for "." and ".." from the return from FileFindNextFile(). (SolidSnake)
   - Added _SetDate and _SetTime to Date.au3. (/dev/null)
   - Added _StringInsert to String.au3. (Celeri)
   - Fixed bug in the _GUICtrlListViewDeleteItem. (gafrost)

1.41 (10 October 2005)
   - Fixed BUG in _ReplaceStringInFile() always replacing multiple occurences on a single line. (Wooltown/LxP)
   - Added _GUICtrlListSelectIndex to GuiList.au3 for single select listbox's. (gafrost)

1.40 (5 October 2005)
   - Fixed error in _ArrayToString example. (/dev/null)
   - Changed _WeekNumberISO() to return the proper ISO weeknr.
     Also removed startday parameter because ISO weeks always starts on Monday. (jdeb)
   - Added _DateToDayOfWeekISO which retruns the ISO day number. 0=Monday - 6= Sunday (jdeb)
   - Fixed bug in _GUICtrlListViewDeleteAllItems. (gafrost)

1.39 (27 September 2005)
   - Updated _InetGetSource. (w0uter)

1.38 (26 September 2005)
   - Fixed GUICtrlTreeViewDeleteItem() selection logic. (gafrost)
   - Fixed GUICtrlTreeViewSelectItem() but removed Helpfile info because function is obsolete. (gafrost)

1.37 (20 September 2005)
   - Added _FileWriteFromArray() to file.au3. (jdeb)
   - Updated _InetGetSource. (w0uter)
   - Updated _TempFile with optional parameters.  (hansh)
   - Fixed documentation for _FileListToArray. (mlazovjp/Dickb)
   - Some code optimization changes: GuiList, GuiTreeView, GuiEdit (gafrost)
   - Fixed logic issue with _GUICtrlListViewSetColumnOrder and _GUICtrlComboGetEditSel. (jdeb)
   - Fixed a few minor documentation issues.

1.36 (5 September 2005)
   - Updated _DateTimeFormat: Added option 5 which returns time in 24 hour HH:MM:SS format. (jdeb)
   - Updated _NowTime: Added optional parameter to select the return format. (jdeb)
   - Fixed Documentation _MouseTrap()  (JPM)
   - Fixed _GUICtrlTreeViewDeleteItem bug in delete of item after adding child items. (gafrost)
   - Updated _StringToHex() and _HexToString() error testing. (JPM)
   - Updated Doc return Value formating. (JPM)

1.35 (31 August 2005)
   - Fixed _IsPressed Example. (gafrost)

1.34 (30 August 2005)
   - Fixed _ArraySearch example to point to Array.au3.
   - Updated _IsPressed Added optional param to function for those that will use
     the function heavily they can pass a handle to the function for the dll.  (gafrost/w0uter)

1.33 (28 August 2005)
   - Updated _ProcessGetPriority script logic and fixed example.  (MSLx Fanboy)

1.32 (28 August 2005)
   - Updated _ProcessGetPriority script logic.  (MSLx Fanboy)
   - Added _IsPressed (Ezzetabi/Jon)
   - Updated Corrected return value for _MouseTrap if no params passed. (gafrost)
   - Added _GUICtrlComboAutoComplete (gafrost)
   - Restored correct example for _GUICtrlListViewGetItemText (jdeb)
   - Added _ArrayPush to Array.au3 (hgeras)
   - Added _ArraySearch to Array.au3 (SolidSnake)
   - Added _ReplaceStringInFile to File.au3 (\dev\null)

1.31 (13 August 2005)
   - Updated _PathMake and _PathSplit documentation.
   - Updated _MouseTrap  (gafrost)
   - Updated _GUICtrlEditScroll: Added $SB_SCROLLCARET - Scrolls the caret into view. (gafrost)
   - Added _ProcessGetPriority to Process.au3  (MSLx Fanboy)
   - Added _FilePrint to File.au3 (Erifash)

1.30 (11 August 2005)
   - Fixed _DayValueToDate() to return Day and Month in the proper format.
   - Fixed _DateTimeFormat() to return HH:MM in proper 24 hour notation for $sType=0.

1.29 (5 August 2005)
   - Added _GUICtrlListViewCopyItems to GUIListView.au3. (gafrost)
   - Fixed source/documentation _INetGetSource
   - Added _MouseTrap to Misc.au3. (gafrost)
   - Fixed _GetIP and _RunDOS doc. (gafrost)
   - Added _Singleton to Misc.au3.
   - Fixed _GUICtrlListViewSort if no items in listview. (gafrost)

1.28 (19 July 2005)
   - Fixed _INetGetSource.au3 example (W0uter)
   - Fixed _FileReadToArray(): added StringStripCR to avoid @CR characters in the Array values. (jdeb)
   - Fixed _GUICtrlListViewDeleteItemsSelected was not working correctly (gafrost)

1.27 (17 July 2005)
   - Added _Radian() and _Degree() to Math.au3 (Erifash)
   - Added _FileList2Array.au3 to File.au3 (Solid)
   - Added _INetGetSource.au3 to Inet.au3 (W0uter)
   - Fixed documentation for _ArraySort() (jdeb)

1.26 (15 July 2005)
   - Bug Fixed: _GUICtrlListViewGetNextItem.  (gafrost)

1.25 (14 July 2005)
   - Bug Fixed: _GUICtrlListViewDeleteAllItems and _GUICtrlListViewDeleteItem
     when _GUICtrlListViewInsertItem used to populate the ListView. (gafrost)

1.24 (13 July 2005)
   - Fixed _GUICtrlListViewGetNextItem.au3 example (gafrost)
   - Fixed _DateIsValid Documentation and Example.

1.23 (07 July 2005)
   - Updated _TimetoTicks: Made parameters optional defaulting to current time (slimshady)
   - Corrected Example for _GUICtrlTreeViewGetParentHandle (gafrost)
   - Added _GUICtrlTreeViewGetParentID to GuiTreeView (gafrost)

1.22 (05 July 2005)
   - Fixed variables already declared in examples for _GUICtrlTreeView??? (gafrost)
   - Added _GUICtrlTreeViewGetParentHandle  (gafrost)
   - Fixed variables already declared in string.au3 (jdeb)

1.21 (22 June 2005)
   - Fixed Dim for $h_Tree in _GUICtrlTreeViewItemGetTree. (gafrost)
   - Added variable passed in to _GUICtrlTreeViewItemGetTree
     and changed example to refelect this change for seperator char. (gafrost)

1.20 (20 June 2005)
   - Removed the following functions from GuiListView.au3:  (gafrost)
     _GUICtrlListViewSetBkColor
     _GUICtrlListViewSetTextBkColor
     _GUICtrlListViewSetTextColorFixed
   - Fixed _GUICtrlTreeViewDeleteItem() to deleted more than 2 levels deep. (gafrost)
   - Added GUICtrlTreeView.au3 UDF's (gafrost)

1.19 (10 June 2005)
   - Fixed some merge issues.

1.18 (9 June 2005)
   - Fixed descending sort issue in multi dimension arrays.
   - Fixed _GUICtrlListViewSort() top handle numeric values correctly. (gafrost)
   - Renamed _GUICtrlListViewGetColumnOrderArray to _GUICtrlListViewGetColumnOrder
      Also corrected documentation for _GUICtrlListViewGetColumnOrder.
      Returns a "|" delimited string instead of an array, now matches
      the _GUICtrlListViewSetColumnOrder in the data type.   (gafrost)

1.17 (6 June 2005)
    - Added _GUICtrlSliderGetPos functions in GUISlider.au3  (gafrost)
   - Fixed _ArraySort lockup Bug.

1.16 (2 June 2005)
   - Fixed _ArraySort to cope with Mixed values and string entries.
    - Added _GUISlider??? functions in GUISlider.au3  (gafrost)
    - Added _GUICtrlListViewInsertColumn, _GUICtrlListViewInsertItem, _GUICtrlListViewJustifyColumn
            _GUICtrlListViewSetColumnOrder, _GuiCtrlListViewSetItemCount, _GUICtrlListViewSort  (gafrost)

1.15 (24 May 2005)
   - Added 2 Functions to GuiListView.au3: _GUICtrlListViewSetItemSelState and
      _GUICtrlListViewSetItemText  (gafrost)
    - Fixed typo in _GUICtrlListViewGetExtendedListViewStyle helppage.
    - Fixed typo in _ViClose helppage.

1.14 (21 May 2005)
   - Fixed _GUICtrlListGetSelItems: returned array, was an array of string numbers
      now an array of numbers.  (gafrost)
   - Fixed _GUICtrlListViewGetSelectedIndices returned array, was an array of
      string numbers now an array of numbers. (gafrost)
   - Updated _GUICtrlListSetHorizontalExtent documentation. (gafrost)

1.13 (19 May 2005)
   - Added _GUICtrlListViewSetCheckState (gafrost)
   - Fixed _GUICtrlListViewGetCurSel: If more than 1 item in listview had same data was returning
      the index of the 1st instance, now correctly returns the index of item selected. (gafrost)
   - Added _GUICtrlMonthCal???? function located in GuiMonthCal.au3 (gafrost)

1.12 (12 May 2005)
   - Added _GUICtrlListViewGetCheckedState to GuiListView. (gafrost)
    - Update several Helpfile pages for the _GUI?? functions. (gafrost)
    - Update _ChooseColor.  (gafrost)
    - Updated _Now(),_NowDate(), _NowTime that it defauts to mm/dd/yyyy and hh:mm:ss when the
      pc's format isn't found in the registry (Win9X).

1.11 (8 May 2005)
   - Added GuiEdit.au3 which has a number of _GUIEdit??? functions for Edit controls. (gafrost)
    - Updated _ChooseColor, _ChooseFont and _GUI??? function due to DllStruct renaming. (gafrost)
    - Corrected wParam to variable name in _GUICtrlEditLineIndex.txt   (gafrost)
    - Fixed example and include for $CB_GETDROPPEDCONTROLRECT   (gafrost)
    - Type-0 in Example: _GUICtrlComboGetEditSel.au3    (gafrost)

1.10 (3 May 2005)
   - Fixed _GUICtrlComboSetHorizontalExtent.txt (gafrost)
   - Added _ChooseColor and _ChooseFont to Misc.au3 (gafrost)

1.09 (1 May 2005)
   - Added _GUITab Functions located in GuiTab.au3.  (gafrost)

1.08 (28 April 2005)
   - Fixed Example for _TickstoTime.au3.
   - Fixed Fixed _ArrayTrim(): $iTrimDirection test.

1.07 (27 April 2005)
   - Renamed All Functions:_GUICtrlComBoBox to _GUICtrlComBo and  _GUICtrlListBox to _GUICtrlList (gafrost)
   - Fixed _DateSplit(), Fix another issue that was introduced with previous fix.
   - Fixed _DateDaysInMonth.au3 example , @Year and @Mon were swapped.
   - Fixed _DateToDayOfWeek.au3, contained a syntax error.

1.06 (26 April 2005)
   - Added _GUICtrlListView functions in GuiListView.au3. (gafrost)
   - Updated _GUICtrlComBoBox & _GUICtrlListBox Documentation and Functions. (gafrost)
   - Fixed _DateSplit(), adding seconds when missing in the input.

1.05 (24 April 2005)
   - Added _GUICtrlComBoBox functions in GuiComboBox.au3. (gafrost)
   - Added _GUICtrlListBox functions in GuiListBox.au3. (gafrost)
    - Replaced _ArraySort() with faster version from LazyCoder/Tylo
   - Fixed _GetIp() to work with the new page layout.
   - Added _PathFull(), _PathMake() and _PathSplit() to File.au3.

1.04 (25 February 2005)
    - Fixed _ArrayMaxIndex() and _ArrayMinIndex() to set to proper initial value.
    - Fixed _ArraySort() issue with only 2 entries not being sorted.
    - Fixed documentation and example for _ArrayToString()
    - Fixed DateAdd() line 84: change == to =
    - Updated DateSplit() to convert date/time portion to number
    - Fixed VISA.au3 from Peppe.

1.03 (6 February 2005)
    *** Updated all documentation to follow the standard used in the helpfile.

    Array.au3:
    - Updated many Array Function with optional parameters like $iBase.(See helpfile for detail)
    - Updated a couple of Function to make use of the new Redim function.
    - Added: _ArraySort()
    - Added: _ArrayTrim()
    - Added: _ArrayCreate()

    Date.au3:
    - Added: _DateAdd, _DateDiff, _DateToDayValue, _DayValueToDate,
             _DateTimeFormat, _DayOfWeek, _DateIsValid,
             _Now(), Nowcalc(), Nowcalcdate(), _NowTime(),
             _NowDate(),_DaysInMonth()_DaysOfWeek()

    File.au3:
    - Removed: _DirRemoveContents , obsolete, replaced by FileDelete() internal command.
    - Removed: _FileAppend , obsolete, replaced by FileWriteLine("Filename",) internal command.
    - Updated: _FileCountLines with a faster version created by Tylo.
    - Added:   _TempFile()

    Inet.au3
    - Added: _INetExplorerCapable, _INetMail, _GetIp

    Math.au3:
    - Added:   _Ceil, _Floor, _MathCheckDiv, _MathCheckDiv

    Misc.au3:
    - Added:  _Iif()

    Process.au3:
    - Updated: _RunDos because the default quotes gave problems in Win9x.

    String.au3:
    - Added:  _StringProper(), _StringEncrypt(), _StringToHex(), HexToString()

   Visa.au3:
    - Added:  _viExecCommand,_viOpen, _viClose, _viFindGpib, _viSetTimeout,
              _viSetAttribute, _viGTL, _viGpibBusReset

1.02 (27 February 2004)
    - Added: _FileCountLines(), _DirRemoveContents()
    - Added: _DateDaysInMonth()
    - Added: _DateIsValidMonthNum(), _DateIsValidWeekdayNum(), _DateIsValidYear()
    - Added: _TimeIsValidHour(), _TimeIsValidMinute(), _TimeIsValidSecond()
    - Added: Usage syntax now included for documentation
    - Added: Documentation updates
    - Changed: _FileReadToArray() so it executes faster
    - Changed: (Internal) Enhanced the way the date/time functions operate
    - Changed: (Internal) File functions now use new file read/write syntax
    - Fixed: _RunDOS() to support executing DOS commands with spaces in the command

1.01 (5 February 2004)
    - Added: _ColorGetRed(), _ColorGetGreen(), _ColorGetBlue()
    - Added: _RunDOS()
    - Fixed: _TicksToTime() and _TimeToTicks()

1.00 (21 January 2004)
    - Initial release


GUI Control Styles

This page contains a list of the common and extended styles that can be used with windows, and also specific styles that can be used with controls. These styles are used in the "style" and/or "exStyle" parameters of many of the GUI functions. To use these values you must #include <GUIConstants.au3> into your script.

Note: The "Value" is given just for reference, you should always use the "name" of the style in order to keep your scripts readable.

Common Styles | Value | Description
Default/forced for GUI creation |  | $GUI_SS_DEFAULT_GUI see GUICreate function.
$WS_BORDER | 0x00800000 | Creates a window that has a thin-line border.
$WS_POPUP | 0x80000000 | Creates a pop-up window. This style cannot be used with the WS_CHILD style.
$WS_CAPTION | 0x00C00000 | Creates a window that has a title bar (includes the WS_BORDER style)
$WS_CLIPCHILDREN | 0x02000000 | Excludes the area occupied by child windows when drawing occurs within the parent window. This style is used when creating the parent window.
$WS_CLIPSIBLINGS | 0x04000000 | Clips child windows relative to each other; that is, when a particular child window receives a WM_PAINT message, the WS_CLIPSIBLINGS style clips all other overlapping child windows out of the region of the child window to be updated. If WS_CLIPSIBLINGS is not specified and child windows overlap, it is possible, when drawing within the client area of a child window, to draw within the client area of a neighboring child window.
$WS_DISABLED | 0x08000000 | Creates a window that is initially disabled.
$WS_DLGFRAME | 0x00400000 | Creates a window that has a border of a style typically used with dialog boxes.
$WS_HSCROLL | 0x00100000 | Creates a window that has a horizontal scroll bar.
$WS_MAXIMIZE | 0x01000000 | Creates a window that is initially maximized.
$WS_MAXIMIZEBOX | 0x00010000 | Creates a window that has a maximize button. Cannot be combined with the WS_EX_CONTEXTHELP style. The WS_SYSMENU style must also be specified.
$WS_MINIMIZE | 0x20000000 | Creates a window that is initially minimized.
$WS_MINIMIZEBOX | 0x00020000 | Creates a window that has a minimize button. Cannot be combined with the WS_EX_CONTEXTHELP style. The WS_SYSMENU style must also be specified.
$WS_OVERLAPPED | 0x00000000 | Creates an overlapped window. An overlapped window has a title bar and a border. Same as the WS_TILED style
$WS_OVERLAPPEDWINDOW | 0x00CF0000 | Creates an overlapped window with the WS_OVERLAPPED, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX styles. Same as the WS_TILEDWINDOW style.
$WS_POPUPWINDOW | 0x80880000 | Creates a pop-up window with WS_BORDER, WS_POPUP, and WS_SYSMENU styles. The WS_CAPTION and WS_POPUPWINDOW styles must be combined to make the window menu visible.
$WS_SIZEBOX | 0x00040000 | Creates a window that has a sizing border. Same as the WS_THICKFRAME style.
$WS_SYSMENU | 0x00080000 | Creates a window that has a window menu on its title bar. The WS_CAPTION style must also be specified.
$WS_THICKFRAME | 0x00040000 | Creates a window that has a sizing border. Same as the WS_SIZEBOX style
$WS_VSCROLL | 0x00200000 | Creates a window that has a vertical scroll bar.
$WS_VISIBLE | 0x10000000 | Creates a window that is initially visible.
$WS_CHILD | 0x40000000 | Creates a child window. A window with this style cannot have a menu bar. This style cannot be used with the WS_POPUP style.
$WS_GROUP | 0x00020000 | Specifies the first control of a group of controls. The group consists of this first control and all controls defined after it, up to the next control with the WS_GROUP style.
$WS_TABSTOP | 0x00010000 | Turns the control into a tab stop, which enables the user to select the control by tabbing through the controls in a dialog box.
$DS_MODALFRAME | 0x00000080 | Creates a dialog box with a modal dialog-box frame that can be combined with a title bar and window menu by specifying the WS_CAPTION and WS_SYSMENU styles.
$DS_SETFOREGROUND | 0x00000200 | This style is useful for modal dialog boxes that require immediate attention from the user regardless of whether the owner window is the foreground window.
$DS_CONTEXTHELP | 0x00002000 | Includes a question mark in the title bar of the dialog box. Cannot be used with the WS_MAXIMIZEBOX or WS_MINIMIZEBOX styles. Same as WS_EX_CONTEXTHELP extended style.

Common Extended Styles | Value | Description
$WS_EX_ACCEPTFILES | 0x00000010 | Allow an edit or input control within the created GUI window to receive filenames via drag and drop. The control must have also the $GUI_DROPACCEPTED state set by GUICtrlSetState.
$WS_EX_APPWINDOW | 0x00040000 | Forces a top-level window onto the taskbar when the window is visible.
$WS_EX_CLIENTEDGE | 0x00000200 | Specifies that a window has a border with a sunken edge.
$WS_EX_CONTEXTHELP | 0x00000400 | Includes a question mark in the title bar of the window. Cannot be used with the WS_MAXIMIZEBOX or WS_MINIMIZEBOX
$WS_EX_DLGMODALFRAME | 0x00000001 | Creates a window that has a double border; the window can, optionally, be created with a title bar by specifying the WS_CAPTION style in the dwStyle parameter.
$WS_EX_MDICHILD | 0x00000040 | Create a child window that will be moved with its parent.(simulation of a MDI window maximize/minimize are not simulated).
$WS_EX_OVERLAPPEDWINDOW | 0x00000300 | Combines the WS_EX_CLIENTEDGE and WS_EX_WINDOWEDGE styles.
$WS_EX_STATICEDGE | 0x00020000 | Creates a window with a three-dimensional border style intended to be used for items that do not accept user input.
$WS_EX_TOPMOST | 0x00000008 | Specifies that a window created with this style should be placed above all non-topmost windows and should stay above them, even when the window is deactivated.
$WS_EX_TRANSPARENT | 0x00000020 | The window appears transparent because the bits of underlying sibling windows have already been painted.
$WS_EX_TOOLWINDOW | 0x00000080 | Creates a tool window; that is, a window intended to be used as a floating toolbar. A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font. A tool window does not appear in the taskbar or in the dialog box that appears when the user presses ALT+TAB. If a tool window has a system menu, its icon is not displayed on the title bar. However, you can display the system menu by typing ALT+SPACE.
$WS_EX_WINDOWEDGE | 0x00000100 | Specifies that a window has a border with a raised edge.
$WS_EX_LAYERED | 0x00080000 | Creates a layered window. Note that this cannot be used for child windows.
$GUI_WS_EX_PARENTDRAG | 0x00100000 | Allow the label or pic control to be used as the title bar to drag the whole the parent window.

Checkbox Styles | Value | Description
Default/forced |  | see GUICtrlCreateCheckbox function.
$BS_3STATE | 0x0005 | Creates a check box in which the box can be unavailable as well as selected or cleared. Use the unavailable state to show that the state of the check box is not determined.
$BS_AUTO3STATE | 0x0006 | Creates a three-state check box in which the state cycles through selected, unavailable, and cleared each time the user selects the check box.
$BS_AUTOCHECKBOX | 0x0003 | Creates a check box in which the check state switches between selected and cleared each time the user selects the check box.
$BS_CHECKBOX | 0x0002 | Creates a small, empty check box with a label displayed to the right of it. To display the text to the left of the check box, combine this flag with the BS_RIGHTBUTTON style.
$BS_LEFT | 0x0100 | Left-aligns the text in the button rectangle on the right side of the check box.
$BS_PUSHLIKE | 0x1000 | Makes a button (such as a check box, three-state check box, or radio button) look and act like a push button. The button looks raised when it isn't pushed or checked, and sunken when it is pushed or checked.
$BS_RIGHT | 0x0200 | Right-aligns text in the button rectangle on the right side of the check box.
$BS_RIGHTBUTTON | 0x0020 | Positions a check box square on the right side of the button rectangle.
$BS_GROUPBOX | 0x0007 | Creates a rectangle in which other buttons can be grouped. Any text associated with this style is displayed in the rectangle’s upper-left corner.
$BS_AUTORADIOBUTTON | 0x0009 | Same as a radio button, except that when the user selects it, the button automatically highlights itself and removes the selection from any other radio buttons with the same style in the same group.

Push Button Styles | Value | Description
Default/forced |  | see GUICtrlCreateButton, GUICtrlCreateCheckbox, GUICtrlCreateRadio functions.
$BS_BOTTOM | 0x0800 | Places the text at the bottom of the button rectangle.
$BS_CENTER | 0x0300 | Centers the text horizontally in the button rectangle.
$BS_DEFPUSHBUTTON | 0x0001 | Creates a push button with a heavy black border. If the button is in a dialog box, the user can select the button by pressing the ENTER key, even when the button does not have the input focus. This style is useful for enabling the user to quickly select the most likely option, or default.
$BS_MULTILINE | 0x2000 | Wraps the button text to multiple lines if the text string is too long to fit on a single line in the button rectangle.
$BS_TOP | 0x0400 | Places text at the top of the button rectangle.
$BS_VCENTER | 0x0C00 | Vertically centers text in the button rectangle.
$BS_ICON | 0x0040 | Specifies that the button displays an icon.
$BS_BITMAP | 0x0080 | Specifies that the button displays a bitmap.
$BS_FLAT | 0x8000 | Specifies that the button is two-dimensional; it does not use the default shading to create a 3-D image.
$BS_NOTIFY | 0x4000 | Enables a button to send BN_KILLFOCUS and BN_SETFOCUS notification messages to its parent window. Note that buttons send the BN_CLICKED notification message regardless of whether it has this style. To get BN_DBLCLK notification messages, the button must have the BS_RADIOBUTTON or BS_OWNERDRAW style.

Combo Styles | Value | Description
Default/forced |  | $GUI_SS_DEFAULT_COMBO see GUICtrlCreateCombo function.
$CBS_AUTOHSCROLL | 0x0040 | Automatically scrolls the text in an edit control to the right when the user types a character at the end of the line. If this style is not set, only text that fits within the rectangular boundary is enabled.
$CBS_DISABLENOSCROLL | 0x0800 | Shows a disabled vertical scroll bar in the list box when the box does not contain enough items to scroll. Without this style, the scroll bar is hidden when the list box does not contain enough items.
$CBS_DROPDOWN | 0x0002 | Displays only the edit control by default. The user can display the list box by selecting an icon next to the edit control.
$CBS_DROPDOWNLIST | 0x0003 | Displays a static text field that displays the current selection in the list box.
$CBS_LOWERCASE | 0x4000 | Converts to lowercase any uppercase characters that are typed into the edit control of a combo box.
$CBS_NOINTEGRALHEIGHT | 0x0400 | Specifies that the combo box will be exactly the size specified by the application when it created the combo box. Usually, Windows CE sizes a combo box so that it does not display partial items.
$CBS_OEMCONVERT | 0x0080 | Converts text typed in the combo box edit control from the Windows CE character set to the OEM character set and then back to the Windows CE set. This style is most useful for combo boxes that contain file names. It applies only to combo boxes created with the CBS_DROPDOWN style.
$CBS_SIMPLE | 0x0001 | Displays the list box at all times. The current selection in the list box is displayed in the edit control.
$CBS_SORT | 0x0100 | Sorts strings that are typed into the list box.
$CBS_UPPERCASE | 0x2000 | Converts to uppercase any lowercase characters that are typed into the edit control of a combo box.

List Styles | Value | Description
Default/forced |  | $GUI_SS_DEFAULT_LIST see GUICtrlCreateList function.
$LBS_DISABLENOSCROLL | 0x1000 | Shows a disabled vertical scroll bar for the list box when the box does not contain enough items to scroll. If you do not specify this style, the scroll bar is hidden when the list box does not contain enough items.
$LBS_NOINTEGRALHEIGHT | 0x0100 | Specifies that the list box will be exactly the size specified by the application when it created the list box.
$LBS_NOSEL | 0x4000 | Specifies that the user can view list box strings but cannot select them.
$LBS_NOTIFY | 0x0001 | Notifies the parent window when the user taps or double-taps a string in the list box.
$LBS_SORT | 0x0002 | Sorts strings in the list box alphabetically.
$LBS_STANDARD | 0xA00003 | Sorts strings in the list box alphabetically. The parent window receives an input message when the user taps or double-taps a string. The list box has borders on all sides. (LBS_NOTIFY | LBS_SORT | WS_VSCROLL | WS_BORDER)
$LBS_USETABSTOPS | 0x0080 | Enables a list box to recognize and expand tab characters when drawing its strings. The default tab positions are 32 dialog box units. A dialog box unit is equal to one-fourth of the current dialog box base-width unit.

Edit/Input Styles | Value | Description
Default/forced |  | $GUI_SS_DEFAULT_EDIT, $GUI_SS_DEFAULT_INPUT see GUICtrlCreateEdit or GUICtrlCreateInput function.
$ES_AUTOHSCROLL | 0x0080 | Automatically scrolls text to the right by 10 characters when the user types a character at the end of the line. When the user presses the ENTER key, the control scrolls all text back to the zero position.
$ES_AUTOVSCROLL | 0x0040 | Scrolls text up one page when the user presses the ENTER key on the last line.
$ES_CENTER | 0x0001 | Centers text in a multiline edit control.
$ES_LOWERCASE | 0x0010 | Converts all characters to lowercase as they are typed into the edit control.
$ES_NOHIDESEL | 0x0100 | Negates the default behavior for an edit control. The default behavior hides the selection when the control loses the input focus and inverts the selection when the control receives the input focus. If you specify ES_NOHIDESEL, the selected text is inverted, even if the control does not have the focus.
$ES_NUMBER | 0x2000 | Accepts into the edit control only digits to be typed.
$ES_OEMCONVERT | 0x0400 | This style is most useful for edit controls that contain file names.
$ES_MULTILINE | 0x0004 | Designates a multiline edit control. The default is a single-line edit control.
$ES_PASSWORD | 0x0020 | Displays an asterisk (*) for each character that is typed into the edit control.
$ES_READONLY | 0x0800 | Prevents the user from typing or editing text in the edit control.
$ES_RIGHT | 0x0002 | Right-aligns text in a multiline edit control.
$ES_UPPERCASE | 0x0008 | Converts all characters to uppercase as they are typed into the edit control.
$ES_WANTRETURN | 0x1000 | Specifies that a carriage return be inserted when the user presses the ENTER key while typing text into a multiline edit control in a dialog box. If you do not specify this style, pressing the ENTER key has the same effect as pressing the dialog box’s default push button. This style has no effect on a single-line edit control.

Progress Bar Styles | Value | Description
$PBS_SMOOTH | 0x01 | Displays progress status in a smooth scrolling bar instead of the default segmented bar.
$PBS_VERTICAL | 0x04 | Displays progress status vertically, from bottom to top.

Up-down Styles | Value | Description
Default/forced |  | $GUI_SS_DEFAULT_UPDOWN see GUICtrlCreateUpdown function.
$UDS_ALIGNLEFT | 0x08 | Positions the up-down control next to the left edge of the buddy window. The buddy window is moved to the right and its width is decreased to accommodate the width of the up-down control.
$UDS_ALIGNRIGHT | 0x04 | Positions the up-down control next to the right edge of the buddy window. The width of the buddy window is decreased to accommodate the width of the up-down control.
$UDS_ARROWKEYS | 0x20 | Causes the up-down control to process the UP ARROW and DOWN ARROW keys on the keyboard.
$UDS_HORZ | 0x40 | Causes the up-down control’s arrows to point left and right instead of up and down.
$UDS_NOTHOUSANDS | 0x80 | Prevents insertion of a thousands separator between every three decimal positions.
$UDS_WRAP | 0x01 | Causes the position to wrap if it is incremented or decremented beyond the end or beginning of the range.

Label/Static Styles | Value | Description
Default/forced |  | $GUI_SS_DEFAULT_LABEL, $GUI_SS_DEFAULT_ICON, $GUI_SS_DEFAULT_PIC see GUICtrlCreateLabel, GUICtrlCreateIcon, GUICtrlCreatePic functions.
$SS_BLACKFRAME | 0x07 | Specifies a box with a frame drawn in the same color as the window frames. This color is black in the default color scheme.
$SS_BLACKRECT | 0x04 | Specifies a rectangle filled with the current window frame color. This color is black in the default color scheme.
$SS_CENTER | 0x01 | Specifies a simple rectangle and centers the error value text in the rectangle. The control automatically wraps words that extend past the end of a line to the beginning of the next centered line.
$SS_CENTERIMAGE | 0x0200 | Specifies that the midpoint of a static control with the SS_BITMAP style will remain fixed when you resize the control. The four sides are adjusted to accommodate a new bitmap. If the bitmap is smaller than the control’s client area, the rest of the client area is filled with the color of the pixel in the upper-left corner of the bitmap. It can be used with static control having only one line of text. Microsoft Windows XP: This style bit no longer results in unused portions of the control being filled with the color of the top left pixel of the bitmap or icon. Unused portions of the control will remain the background color.
$SS_ETCHEDFRAME | 0x12 | Draws the frame of the static control using the EDGE_ETCHED edge style.
$SS_ETCHEDHORZ | 0x10 | Draws the top and bottom edges of the static control using the EDGE_ETCHED edge style.
$SS_ETCHEDVERT | 0x11 | Draws the left and right edges of the static control using the EDGE_ETCHED edge style.
$SS_GRAYFRAME | 0x08 | Specifies a box with a frame drawn with the same color as the screen background (desktop). This color is gray in the default color scheme
$SS_GRAYRECT | 0x05 | Specifies a rectangle filled with the current screen background color. This color is gray in the default color scheme.
$SS_LEFT | 0x0000 | Specifies a simple rectangle and left-aligns the text in the rectangle. The text is formatted before it is displayed. Words that extend past the end of a line are automatically wrapped to the beginning of the next left-aligned line. Words that are longer than the width of the control are truncated.
$SS_LEFTNOWORDWRAP | 0x0C | Specifies a rectangle and left-aligns the text in the rectangle. Tabs are expanded, but words are not wrapped. Text that extends past the end of a line is clipped.
$SS_NOPREFIX | 0x80 | Prevents interpretation of any ampersand (&) characters in the control’s text as accelerator prefix characters. An application can combine SS_NOPREFIX with other styles by using the bitwise OR (|) operator. This can be useful when file names or other strings that might contain an ampersand (&) must be displayed within a static control in a dialog box.
$SS_NOTIFY | 0x0100 | Sends the parent window the STN_CLICKED notification when the user clicks the control.
$SS_RIGHT | 0x0002 | Specifies a rectangle and right-aligns the specified text in the rectangle.
$SS_RIGHTJUST | 0x0400 | Specifies that the lower right corner of a static control with the SS_BITMAP or SS_ICON style is to remain fixed when the control is resized. Only the top and left sides are adjusted to accommodate a new bitmap or icon.
$SS_SIMPLE | 0x0B | Specifies a simple rectangle and displays a single line of left-aligned text in the rectangle. The text line cannot be shortened or altered in any way. Also, if the control is disabled, the control does not gray its text.
$SS_SUNKEN | 0x1000 | Draws a half-sunken border around a static control.
$SS_WHITEFRAME | 0x09 | Specifies a box with a frame drawn with the same color as the window background. This color is white in the default color scheme.
$SS_WHITERECT | 0x06 | Specifies a rectangle filled with the current window background color. This color is white in the default color scheme.

Tab Styles | Value | Description
Default/forced |  | see GUICtrlCreateTab function.
$TCS_SCROLLOPPOSITE | 0x0001 | Unneeded tabs scroll to the opposite side of the control when a tab is selected.
$TCS_BOTTOM | 0x0002 | Tabs appear at the bottom of the control. This value equals TCS_RIGHT. This style is not supported if you use ComCtl32.dll version 6.
$TCS_RIGHT | 0x0002 | Tabs appear vertically on the right side of controls that use the TCS_VERTICAL style. This value equals TCS_BOTTOM. This style is not supported if you use visual styles.
$TCS_MULTISELECT | 0x0004 | Multiple tabs can be selected by holding down CTRL when clicking. This style must be used with the TCS_BUTTONS style.
$TCS_FLATBUTTONS | 0x0008 | Selected tabs appear as being indented into the background while other tabs appear as being on the same plane as the background. This style only affects tab controls with the TCS_BUTTONS style.
$TCS_FORCEICONLEFT | 0x0010 | Icons are aligned with the left edge of each fixed-width tab. This style can only be used with the TCS_FIXEDWIDTH style.
$TCS_FORCELABELLEFT | 0x0020 | Labels are aligned with the left edge of each fixed-width tab; that is, the label is displayed immediately to the right of the icon instead of being centered. This style can only be used with the TCS_FIXEDWIDTH style, and it implies the TCS_FORCEICONLEFT style.
$TCS_HOTTRACK | 0x0040 | Items under the pointer are automatically highlighted
$TCS_VERTICAL | 0x0080 | Tabs appear at the left side of the control, with tab text displayed vertically. This style is valid only when used with the TCS_MULTILINE style. To make tabs appear on the right side of the control, also use the TCS_RIGHT style. This style is not supported if you use ComCtl32.dll version 6.
$TCS_TABS | 0x0000 | Tabs appear as tabs, and a border is drawn around the display area. This style is the default.
$TCS_BUTTONS | 0x0100 | Tabs appear as buttons, and no border is drawn around the display area.
$TCS_SINGLELINE | 0x0000 | Only one row of tabs is displayed. The user can scroll to see more tabs, if necessary. This style is the default.
$TCS_MULTILINE | 0x0200 | Multiple rows of tabs are displayed, if necessary, so all tabs are visible at once.
$TCS_RIGHTJUSTIFY | 0x0000 | The width of each tab is increased, if necessary, so that each row of tabs fills the entire width of the tab control. This window style is ignored unless the TCS_MULTILINE style is also specified.
$TCS_FIXEDWIDTH | 0x0400 | All tabs are the same width. This style cannot be combined with the TCS_RIGHTJUSTIFY style.
$TCS_RAGGEDRIGHT | 0x0800 | Rows of tabs will not be stretched to fill the entire width of the control. This style is the default.
$TCS_FOCUSONBUTTONDOWN | 0x1000 | The tab control receives the input focus when clicked.
$TCS_OWNERDRAWFIXED | 0x2000 | The parent window is responsible for drawing tabs.
$TCS_TOOLTIPS | 0x4000 | The tab control has a tooltip control associated with it.
$TCS_FOCUSNEVER | 0x8000 | The tab control does not receive the input focus when clicked.

Avi Clip Styles | Value | Description
Default/forced |  | $GUI_SS_DEFAULT_AVI see GUICtrlCreateAvi function.
$ACS_AUTOPLAY | 0x04 | Starts playing the animation as soon as the AVI clip is opened.
$ACS_CENTER | 0x01 | Centers the animation in the animation control's window.
$ACS_TRANSPARENT | 0x02 | Allows you to match an animation's background color to that of the underlying window, creating a "transparent" background. (Default value)
$ACS_NONTRANSPARENT | 0x10 | To override default ACS_TRANSPARENT

Date Styles | Value | Description
Default/forced |  | $GUI_SS_DEFAULT_DATE see GUICtrlCreateDate function.
$DTS_UPDOWN | 0x01 | Places an up-down control to the right of a DTP control to modify time values. This style can be used instead of the drop-down month calendar, which is the default style.
$DTS_SHOWNONE | 0x02 | Enables the control to accept “no date” as a valid selection state.
$DTS_LONGDATEFORMAT | 0x04 | Displays the date in long format. The default format string for this style is defined by LOCALE_SLONGDATEFORMAT, which produces output like “Friday, April 19, 1998.”
$DTS_TIMEFORMAT | 0x09 | Displays the time. The default format string for this style is defined by LOCALE_STIMEFORMAT, which produces output like “5:31:42 PM.”
$DTS_RIGHTALIGN | 0x20 | The drop-down month calendar will be right-aligned with the control instead of left-aligned, which is the default.
$DTS_SHORTDATEFORMAT | 0x00 | Displays the date in short format. The default format string for this style is defined by LOCALE_SSHORTDATE, which produces output like "4/19/96".

MonthCal Styles | Value | Description
Default/forced |  | see GUICtrlCreateMonthCal function.
$MCS_NOTODAY | 0x10 | The month calendar control will not display the "today" date at the bottom of the control.
$MCS_NOTODAYCIRCLE | 0x08 | The month calendar control will not circle the "today" date.
$MCS_WEEKNUMBERS | 0x04 | The month calendar control will display week numbers (1-52) to the left of each row of days. Week 1 is defined as the first week that contains at least four days.

TreeView Styles | Value | Description
Default/forced |  | $GUI_SS_DEFAULT_TREEVIEW see GUICtrlCreateTreeView function.
$TVS_HASBUTTONS | 0x0001 | Displays plus (+) and minus (-) buttons next to parent items. The user clicks the buttons to expand or collapse a parent item's list of child items. To include buttons with items at the root of the tree view, TVS_LINESATROOT must also be specified.
$TVS_HASLINES | 0x0002 | Uses lines to show the hierarchy of items.
$TVS_LINESATROOT | 0x0004 | Uses lines to link items at the root of the tree view control. This value is ignored if TVS_HASLINES is not also specified.
$TVS_DISABLEDRAGDROP | 0x0010 | Prevents the tree view control from sending TVN_BEGINDRAG notification messages.
$TVS_SHOWSELALWAYS | 0x0020 | Causes a selected item to remain selected when the tree view control loses focus.
$TVS_RTLREADING | 0x0040 | Normal windows display text left-to-right (LTR). Windows can be mirrored to display languages such as Hebrew or Arabic that read right-to-left (RTL). Normally, tree view text will be displayed in same direction as the the text in its parent window. If TVS_RTLREADING is set, tree view text will read in the opposite direction from the text in the parent window.
$TVS_NOTOOLTIPS | 0x0080 | The tree view control does not support tooltips.
$TVS_CHECKBOXES | 0x0100 |
$TVS_TRACKSELECT | 0x0200 | Enables hot tracking in a tree view control.
$TVS_SINGLEEXPAND | 0x0400 | When this style is enabled, changing the selection in the tree view will automatically cause the item being selected to expand and the item being unselected to collapse. If the mouse is used to single-click the selected item and that item is closed, it will be expanded. If the user holds the CTRL key down while selecting an item, the item being unselected will not be collapsed.
$TVS_FULLROWSELECT | 0x1000 | Enables full-row selection in the tree view. The entire row of the selected item is highlighted, and clicking anywhere on an item's row will cause it to be selected. This style cannot be used in conjunction with the TVS_HASLINES style.
$TVS_NOSCROLL | 0x2000 | Disables horizontal scrolling in the control. The control will not display any horizontal scroll bars.
$TVS_NONEVENHEIGHT | 0x4000 | The height of the items can be set to an odd height with the TVM_SETITEMHEIGHT message. By default, the height of items must be an even value.

Slider Styles | Value | Description
Default/forced |  | $GUI_SS_DEFAULT_SLIDER see GUICtrlCreateSlider function.
$TBS_AUTOTICKS | 0x0001 | Adds tick marks when you set the range on the trackbar by using the TBM_SETRANGE message.
$TBS_BOTH | 0x0008 | Places ticks on both sides of the trackbar.
$TBS_BOTTOM | 0x0000 | Places ticks on the bottom of a horizontal trackbar.
$TBS_HORZ | 0x0000 | Specifies a horizontal trackbar. This is the default.
$TBS_VERT | 0x0002 | Places ticks on the left side of a vertical trackbar.
$TBS_NOTHUMB | 0x0080 | Specifies that the trackbar has no slider.
$TBS_NOTICKS | 0x0010 | Specifies that no ticks are placed on the trackbar.
$TBS_LEFT | 0x0004 | Places ticks on the left side of a vertical trackbar.
$TBS_RIGHT | 0x0000 | Places ticks on the right side of a vertical trackbar.
$TBS_TOP | 0x0004 | Places ticks on the top of a horizontal trackbar.

ListView Styles | Value | Description
Default/forced |  | $GUI_SS_DEFAULT_LISTVIEW see GUICtrlCreateListView function.
$LVS_ICON | 0x0000 | This style specifies icon view.
$LVS_REPORT | 0x0001 | This style specifies report view.
$LVS_SMALLICON | 0x0002 | This style specifies small icon view.
$LVS_LIST | 0x0003 | This style specifies list view.
$LVS_EDITLABELS | 0x0200 | Item text can be edited in place.
$LVS_NOCOLUMNHEADER | 0x4000 | Column headers are not displayed in report view. By default, columns have headers in report view.
$LVS_NOSORTHEADER | 0x8000 | Column headers do not work like buttons. This style can be used if clicking a column header in report view does not carry out an action, such as sorting.
$LVS_SINGLESEL | 0x0004 | Only one item at a time can be selected.
$LVS_SHOWSELALWAYS | 0x0008 | The selection, if any, is always shown, even if the control does not have the focus.
$LVS_SORTASCENDING | 0x0010 | Item indices are sorted based on item text in ascending order.
$LVS_SORTDESCENDING | 0x0020 | Item indices are sorted based on item text in descending order.
$LVS_NOLABELWRAP | 0x0080 | Item text is displayed on a single line in icon view. By default, item text may wrap in icon view.

ListView Extended Styles | Value | Description
$LVS_EX_FULLROWSELECT | 0x00000020 | When an item is selected, the item and all its subitems are highlighted.
$LVS_EX_GRIDLINES | 0x00000001 | Displays gridlines around items and subitems.
$LVS_EX_HEADERDRAGDROP | 0x00000010 | Enables drag-and-drop reordering of columns in a list view control.
$LVS_EX_TRACKSELECT | 0x00000008 | Enables hot-track selection in a list view control. Hot track selection means that an item is automatically selected when the cursor remains over the item for a certain period of time
$LVS_EX_CHECKBOXES | 0x00000004 | Enables check boxes for items in a list view control.
$LVS_EX_BORDERSELECT | 0x00008000 | If this style is set, when an item is selected the border color of the item changes rather than the item being highlighted.
$LVS_EX_DOUBLEBUFFER | 0x00010000 |
$LVS_EX_FLATSB | 0x00000100 | Enables flat scroll bars in the list view.
$LVS_EX_MULTIWORKAREAS | 0x00002000 |
$LVS_EX_SNAPTOGRID | 0x00080000 |
$LVS_EX_SUBITEMIMAGES | 0x00000002 | Allows images to be displayed for subitems.


Send Key list

Quick reference for the Send( "keys" [, flag] ) Command. ^ Ctrl ! Alt + Shift # Win

AutoIt can send all ASCII and Extended ASCII characters (0-255), to send UNICODE characters you must use the "ASC" option and the code of the character you wish to Send(see {ASC} below).

To send the ASCII value A (same as pressing ALT+065 on the numeric keypad)

Send("{ASC 065}")

(When using 2 digit ASCII codes you must use a leading 0, otherwise an obsolete 437 code page is used).

To send UNICODE characters enter the character code, for example this sends a Chinese character

Send("{ASC 2709}")

Single keys can also be repeated, e.g.

Send("{DEL 4}") ;Presses the DEL key 4 times
Send("{S 30}") ;Sends 30 'S' characters
Send("+{TAB 4}") ;Presses SHIFT+TAB 4 times

To hold a key down (generally only useful for games)

Send("{a down}") ;Holds the A key down
Send("{a up}") ;Releases the A key

If you with to use a variable for the count, try

$n = 4
Send("+{TAB " & $n & "}")

If you wish to send the ASCII value A four times, then try

$x = Chr(65)
Send("{" & $x & " 4}")

Most laptop computer keyboards have a special Fn key. This key cannot be simulated.

Note, by setting the flag parameter to 1 the "keys" parameter is sent RAW. This is useful when you want to send some text copied from a variable and you want the text sent exactly as written.

Send is quite useful because windows can be navigated without needing a mouse.

For example, open Folder Options (in the control panel) and try the following:

Send("{TAB}") | Navigate to next control (button, checkbox, etc)
Send("+{TAB}") | Navigate to previous control.
Send("^{TAB}") | Navigate to next WindowTab (on a Tabbed dialog window)
Send("^+{TAB}") | Navigate to previous WindowTab.
Send("{SPACE}") | Can be used to toggle a checkbox or click a button.
Send("{+}") | Usually checks a checkbox (if it's a "real" checkbox.)
Send("{-}") | Usually unchecks a checkbox.
Send("{NumPadMult}") | Recursively expands folders in a SysTreeView32.

Use Alt-key combos to access menu items. Also, open Notepad and try the following:

Send("!f") | Send Alt+f, the access key for Notepad's file menu. Try other letters!
Send("{DOWN}") | Move down a menu.
Send("{UP}") | Move up a menu.
Send("{LEFT}") | Move leftward to new menu or expand a submenu.
Send("{RIGHT}") | Move rightward to new menu or collapse a submenu.

See Windows' Help--press Win+F1--for a complete list of keyboard shortcuts if you don't know the importance of Alt+F4, PrintScreen, Ctrl+C, and so on.

Send Command (if zero flag) | Resulting Keypress
{!} | !
{#} | #
{+} | +
{^} | ^
{{} | {
{}} | }
{SPACE} | SPACE
{ENTER} | ENTER key on the main keyboard
{ALT} | ALT
{BACKSPACE} or {BS} | BACKSPACE
{DELETE} or {DEL} | DELETE
{UP} | Up arrow
{DOWN} | Down arrow
{LEFT} | Left arrow
{RIGHT} | Right arrow
{HOME} | HOME
{END} | END
{ESCAPE} or {ESC} | ESCAPE
{INSERT} or {INS} | INS
{PGUP} | PGUP
{PGDN} | PGDN
{F1} - {F12} | Function keys
{TAB} | TAB
{PRINTSCREEN} | PRINTSCR
{LWIN} | Left Windows key
{RWIN} | Right Windows key
{NUMLOCK} | NUMLOCK
{BREAK} | for Ctrl+Break processing
{PAUSE} | PAUSE
{CAPSLOCK} | CAPSLOCK
{NUMPAD0} - {NUMPAD9} | Numpad digits
{NUMPADMULT} | Numpad Multiply
{NUMPADADD} | Numpad Add
{NUMPADSUB} | Numpad Subtract
{NUMPADDIV} | Numpad Divide
{NUMPADDOT} | Numpad period
{NUMPADENTER} | Enter key on the numpad
{APPSKEY} | Windows App key
{LALT} | Left ALT key
{RALT} | Right ALT key
{LCTRL} | Left CTRL key
{RCTRL} | Right CTRL key
{LSHIFT} | Left Shift key
{RSHIFT} | Right Shift key
{SLEEP} | Computer SLEEP key
{ALTDOWN} | Holds the ALT key down until {ALTUP} is sent
{SHIFTDOWN} | Holds the SHIFT key down until {SHIFTUP} is sent
{CTRLDOWN} | Holds the CTRL key down until {CTRLUP} is sent
{LWINDOWN} | Holds the left Windows key down until {LWINUP} is sent
{RWINDOWN} | Holds the right Windows key down until {RWINUP} is sent
{ASC nnnn} | Send the ALT+nnnn key combination
{BROWSER_BACK} | 2000/XP Only: Select the browser "back" button
{BROWSER_FORWARD} | 2000/XP Only: Select the browser "forward" button
{BROWSER_REFRESH} | 2000/XP Only: Select the browser "refresh" button
{BROWSER_STOP} | 2000/XP Only: Select the browser "stop" button
{BROWSER_SEARCH} | 2000/XP Only: Select the browser "search" button
{BROWSER_FAVORITES} | 2000/XP Only: Select the browser "favorites" button
{BROWSER_HOME} | 2000/XP Only: Launch the browser and go to the home page
{VOLUME_MUTE} | 2000/XP Only: Mute the volume
{VOLUME_DOWN} | 2000/XP Only: Reduce the volume
{VOLUME_UP} | 2000/XP Only: Increase the volume
{MEDIA_NEXT} | 2000/XP Only: Select next track in media player
{MEDIA_PREV} | 2000/XP Only: Select previous track in media player
{MEDIA_STOP} | 2000/XP Only: Stop media player
{MEDIA_PLAY_PAUSE} | 2000/XP Only: Play/pause media player
{LAUNCH_MAIL} | 2000/XP Only: Launch the email application
{LAUNCH_MEDIA} | 2000/XP Only: Launch media player
{LAUNCH_APP1} | 2000/XP Only: Launch user app1
{LAUNCH_APP2} | 2000/XP Only: Launch user app2


Function Asc

Function Reference

Asc

Returns the ASCII code of a character.

Asc ( "char" )

Parameters

char The character to get the code for. If a string is used, the code for the first character is given.

Return Value

Returns the ASCII code of the specified char.

Remarks

See the Appendix for a complete ASCII table.
Asc("0") == 48, Asc("9") == 57, Asc("A") == 65, Asc("Z") == 90, Asc("a") == 97, Asc("z") == 122, etc.

Related

AscW, Chr, ChrW

Example

$code = Asc("A")
MsgBox(0, "ASCII code for A:", $code)


Function AscW

Function Reference

AscW

Returns the unicode code of a character.

AscW ( "char" )

Parameters

char The character to get the code for. If a string is used, the code for the first character is given.

Return Value

Returns the unicode code of the specified char.

Remarks

See the Appendix for a complete ASCII table.

Related

Asc, Chr, ChrW

Example

$code = AscW("A")
MsgBox(0, "Unicode code for A:", $code)


Function AutoItSetOption

Function Reference

AutoItSetOption

Changes the operation of various AutoIt functions/parameters.

AutoItSetOption ( "option" [, param] )

Parameters

option | The option to change. See Remarks.
param | [optional] The value to assign to the option. The type and meaning vary by option. See remarks below. If the param is not provided, then the function just returns the value already assigned to the option. The keyword Default can be used for the parameter to reset the option to its default value.

Return Value

Returns the value of the previous setting for the option.

Remarks

You may use Opt() as an alternative to AutoItSetOption().

AutoIt will halt with an error message if the requested option is unknown. Options are as follows:

Option | Param
CaretCoordMode | Sets the way coords are used in the caret functions, either absolute coords or coords relative to the current active window: 0 = relative coords to the active window 1 = absolute screen coordinates (default) 2 = relative coords to the client area of the active window
ColorMode | Sets the way colors are defined, either RGB or BGR. RGB is the default but in previous versions of AutoIt (pre 3.0.102) BGR was the default: 0 = Colors are defined as RGB (0xRRGGBB) (default) 1 = Colors are defined as BGR (0xBBGGRR) (the mode used in older versions of AutoIt)
ExpandEnvStrings | Changes how literal strings and % symbols are interpreted. By default strings are treated literally, this option allows you to use %environment% variables inside strings, e.g., "The temp directory is: %temp%". 1 = expand environment variables (similar to AutoIt v2) 0 = do not expand environment variables (default) Without this option the usual way would be: "The temp directory is: " & EnvGet("temp")
ExpandVarStrings | Changes how literal strings and variable/macro ($ and @) symbols are interpreted. By default strings are treated literally, this option allows you to use variables and macros inside strings, e.g., "The value of var1 is $var1$". 1 = expand variables (when in this mode and you want to use a literal $ or @ then double it up: "This is a single dollar $$ sign". 0 = do not expand variables (default)
FtpBinaryMode | Changes how FTP files are transferred. 1 = Binary (default) 0 = ASCII
GUICloseOnESC | When ESC is pressed on a GUI the $GUI_EVENT_CLOSE message is sent. This option toggles this behavior on and off. 1 = Send the $GUI_EVENT_CLOSE message when ESC is pressed (default). 0 = Don't send the $GUI_EVENT_CLOSE message when ESC is pressed.
GUICoordMode | Alters the position of a control defined by GUICtrlSetPos. 1 = absolute coordinates (default) still relative to the dialog box. 0 = relative position to the start of the last control (upper left corner). 2 = cell positionining relative to current cell. A -1 for left or top parameter don't increment the start. So next line is -1,offset; next cell is offset,-1; current cell is -1,-1. Obviously "offset" cannot be -1 which reserved to indicate the no increment. But if you can use a multiple of the width you choose to skip or go back.
GUIDataSeparatorChar | Define the character which delimits subitems in GUICtrlSetData. The default character is '|'.
GUIOnEventMode | Enable/disable OnEvent functions notifications. 0 = (default) disable. 1 = enable.
GUIResizeMode | Change default resizing for a control. 0 = (default) keep default control resizing. <1024 = anytype of resizing see GUICtrlSetResizing.
GUIEventOptions | Change special event behavior or GUI function return values. 0 = (default) Windows behavior on click on Minimize,Restore, Maximize, Resize. 1 = suppress windows behavior on minimize, restore or maximize click button or window resize. Just sends the notification.
MouseClickDelay | Alters the length of the brief pause in between mouse clicks. Time in milliseconds to pause (default=10).
MouseClickDownDelay | Alters the length a click is held down before release. Time in milliseconds to pause (default=10).
MouseClickDragDelay | Alters the length of the brief pause at the start and end of a mouse drag operation. Time in milliseconds to pause (default=250).
MouseCoordMode | Sets the way coords are used in the mouse functions, either absolute coords or coords relative to the current active window: 0 = relative coords to the active window 1 = absolute screen coordinates (default) 2 = relative coords to the client area of the active window
MustDeclareVars | If this option is used then all variables must be pre-declared with Dim, Local or Global before they can be used - removes the chance for misspelled variables causing bugs. 1 = Variables must be pre-declared 0 = Variables don't need to be pre-declared (default)
OnExitFunc | Sets the name of the function called when AutoIt exits (default is OnAutoItExit).
PixelCoordMode | Sets the way coords are used in the pixel functions, either absolute coords or coords relative to the current active window: 0 = relative coords to the active window 1 = absolute screen coordinates (default) 2 = relative coords to the client area of the active window
RunErrorsFatal | Sets if the script should terminate with a fatal error if a Run/RunWait function fails due to bad paths/file not found/Bad login IDs: 1 = fatal error (default) 0 = silent error (@error set to 1)
SendAttachMode | Specifies if AutoIt attaches input threads when using Send() function. When not attaching (default mode=0) detecting the state of capslock/scrolllock and numlock can be unreliable under NT4. However, when you specify attach mode=1 the Send("{... down/up}") syntax will not work and there may be problems with sending keys to "hung" windows. ControlSend() ALWAYS attaches and is not affected by this mode. 0 = don't attach (default) 1 = attach
SendCapslockMode | Specifies if AutoIt should store the state of capslock before a Send function and restore it afterwards. 0 = don't store/restore 1 = store and restore (default)
SendKeyDelay | Alters the the length of the brief pause in between sent keystrokes. Time in milliseconds to pause (default=5). Sometimes a value of 0 does not work; use 1 instead.
SendKeyDownDelay | Alters the length of time a key is held down before being released during a keystroke. For applications that take a while to register keypresses (and many games) you may need to raise this value from the default. Time in milliseconds to pause (default=5).
TCPTimeout | Defines the time before TCP functions stop if no communication. Time in milliseconds before timeout (default=100).
TrayAutoPause | Script pauses when click on tray icon. 0 = no pause 1 = pause (default). If there is no DefaultMenu no pause will occurs.
TrayIconDebug | If enabled shows the current script line in the tray icon tip to help debugging. 0 = no debug information (default) 1 = show debug
TrayIconHide | Hides the AutoIt tray icon. Note: The icon will still initially appear ~750 milliseconds. 0 = show icon (default) 1 = hide icon
TrayMenuMode | Extend the behaviour of the script tray icon/menu. This can be done with a combination (adding) of the following values. 0 = default menu items (Script Paused/Exit) are appended to the usercreated menu; usercreated checked items will automatically unchecked; if you double click the tray icon then the controlid is returned which has the "Default"-style (default). 1 = no default menu 2 = usercreated checked items will not automatically unchecked if you click it 4 = don't return the menuitemID which has the "default"-style in the main contextmenu if you double click the tray icon 8 = turn off auto check of radio item groups
TrayOnEventMode | Enable/disable OnEvent functions notifications for the tray. 0 = (default) disable 1 = enable
WinDetectHiddenText | Specifies if hidden window text can be "seen" by the window matching functions. 0 = Do not detect hidden text (default) 1 = Detect hidden text
WinSearchChildren | Allows the window search routines to search child windows as well as top-level windows. 0 = Only search top-level windows (default) 1 = Search top-level and child windows
WinTextMatchMode | Alters the method that is used to match window text during search operations. 1 = Complete / Slow mode (default) 2 = Quick mode In quick mode AutoIt can usually only "see" dialog text, button text and the captions of some controls. In the default mode much more text can be seen (for instance the contents of the Notepad window). If you are having performance problems when performing many window searches then changing to the "quick" mode may help.
WinTitleMatchMode | Alters the method that is used to match window titles during search operations. 1 = Match the title from the start (default) 2 = Match any substring in the title 3 = Exact title match 4 = Advanced mode, see Window Titles & Text (Advanced) -1 to -4 = force lower case match according to other type of match.
WinWaitDelay | Alters how long a script should briefly pause after a successful window-related operation. Time in milliseconds to pause (default=250).

Related

Many!

Example

; copy any you want to change ;default value is listed first

Opt("CaretCoordMode", 1) ;1=absolute, 0=relative, 2=client
Opt("ColorMode", 0) ;0=RRGGBB color, 1=BBGGRR color
Opt("ExpandEnvStrings", 0) ;0=don't expand, 1=do expand
Opt("ExpandVarStrings", 0) ;0=don't expand, 1=do expand
Opt("FtpBinaryMode", 1) ;1=binary, 0=ASCII
Opt("GUICloseOnESC", 1) ;1=ESC closes, 0=ESC won't close
Opt("GUICoordMode", 1) ;1=absolute, 0=relative, 2=cell
Opt("GUIDataSeparatorChar","|") ;"|" is the default
Opt("GUIOnEventMode", 0) ;0=disabled, 1=OnEvent mode enabled
Opt("GUIResizeMode", 0) ;0=no resizing, <1024 special resizing
Opt("GUIEventOptions",0) ;0=default, 1=just notification, 2=GuiCtrlRead tab index
Opt("MouseClickDelay", 10) ;10 milliseconds
Opt("MouseClickDownDelay", 10) ;10 milliseconds
Opt("MouseClickDragDelay", 250) ;250 milliseconds
Opt("MouseCoordMode", 1) ;1=absolute, 0=relative, 2=client
Opt("MustDeclareVars", 0) ;0=no, 1=require pre-declare
Opt("OnExitFunc","OnAutoItExit");"OnAutoItExit" called
Opt("PixelCoordMode", 1) ;1=absolute, 0=relative, 2=client
Opt("RunErrorsFatal", 1) ;1=fatal, 0=silent set @error
Opt("SendAttachMode", 0) ;0=don't attach, 1=do attach
Opt("SendCapslockMode", 1) ;1=store and restore, 0=don't
Opt("SendKeyDelay", 5) ;5 milliseconds
Opt("SendKeyDownDelay", 1) ;1 millisecond
Opt("TCPTimeout",100) ;100 milliseconds
Opt("TrayAutoPause",1) ;0=no pause, 1=Pause
Opt("TrayIconDebug", 0) ;0=no info, 1=debug line info
Opt("TrayIconHide", 0) ;0=show, 1=hide tray icon
Opt("TrayMenuMode",0) ;0=append, 1=no default menu, 2=no automatic check, 4=menuitemID not return
Opt("TrayOnEventMode",0) ;0=disable, 1=enable
Opt("WinDetectHiddenText", 0) ;0=don't detect, 1=do detect
Opt("WinSearchChildren", 1) ;0=no, 1=search children also
Opt("WinTextMatchMode", 1) ;1=complete, 2=quick
Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("WinWaitDelay", 250) ;250 milliseconds


Function AutoItWinGetTitle

Function Reference

AutoItWinGetTitle

Retrieves the title of the AutoIt window.

AutoItWinGetTitle ( )

Parameters

None.

Return Value

Returns a string containing the title of the AutoIt window.

Remarks

None.

Related

AutoItWinSetTitle, WinGetTitle

Example

$a = AutoItWinGetTitle()


Function AutoItWinSetTitle

Function Reference

AutoItWinSetTitle

Changes the title of the AutoIt window.

AutoItWinSetTitle ( "newtitle" )

Parameters

newtitle The new title to give to the window.

Return Value

None.

Remarks

The AutoIt window is usually hidden. The purpose of changing the title is to allow other programs (or other AutoIt scripts) to interact with AutoIt.

Related

AutoItWinGetTitle, WinSetTitle

Example

AutoItWinSetTitle("My AutoIt Window")


Function Chr

Function Reference

Chr

Returns a character corresponding to an ASCII code.

Chr ( ASCIIcode )

Parameters

ASCIIcode An ASCII code in the range 0-255 (e.g., 65 returns the capital letter A).

Return Value

Success: | Returns a string containing the ASCII representation of the given code.
Failure: | Returns a blank string and sets @error to 1 if the ASCIIcode is greater than 255.

Remarks

Chr(48) == "0", Chr(57) == "9", Chr(65) == "A", Chr(90) == "Z", Chr(97) == "a", Chr(122) = "z", etc.
A complete ASCII table is in the Appendix.

Related

Asc, AscW, ChrW, String

Example

$text = ""
For $i = 65 to 90
$text = $text & Chr($i)
Next
MsgBox(0, "Uppercase alphabet", $text)


Function ChrW

Function Reference

ChrW

Returns a character corresponding to a unicode code.

ChrW ( UNICODEcode )

Parameters

UNICODEcode A unicode code in the range 0-65535 (e.g., 65 returns the capital letter A).

Return Value

Success: | Returns a string containing the representation of the given code.
Failure: | Returns a blank string and sets @error to 1 if the UNICODEcode is greater than 65535.

Remarks

A complete ASCII table is in the Appendix.

Related

Asc, AscW, Chr, String

Example

$text = ""
For $i = 256 to 512
$text = $text & ChrW($i)
Next
MsgBox(0, "Unicode chars 256 to 512", $text)


Function ControlClick

Function Reference

ControlClick

Sends a mouse click command to a given control.

ControlClick ( "title", "text", controlID [, button [, clicks [, x [, y ]]]] )

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.
button | [optional] The button to click, "left", "right" or "middle". Default is the left button.
clicks | [optional] The number of times to click the mouse. Default is 1.
x | [optional] The x position to click within the control. Default is center.
y | [optional] The y position to click within the control. Default is center.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

Some controls will resist clicking unless they are the active window. Use the WinActivate() function to force the control's window to the top before using ControlClick().
Using 2 for the number of clicks will send a double-click message to the control - this can even be used to launch programs from an explorer control!

Related

ControlCommand, MouseClick, WinActivate

Example

ControlClick("Untitled -", "", "MDIClient1")


Function ControlCommand

Function Reference

ControlCommand

Sends a command to a control.

ControlCommand ( "title", "text", controlID, "command" [, "option"] )

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.
command | The command to send to the control.
option | [optional] Additional parameter required by some commands.

Return Value

Depends on command as table below shows. In case of an error (such as an invalid command or window/control), @error=1.
Command, Option | Return Value
"IsVisible", "" | Returns 1 if Control is visible, 0 otherwise
"IsEnabled", "" | Returns 1 if Control is enabled, 0 otherwise
"ShowDropDown", "" | Drops a ComboBox
"HideDropDown", "" | UNdrops a ComboBox
"AddString", 'string' | Adds a string to the end in a ListBox or ComboBox
"DelString", occurrence | Deletes a string according to occurrence in a ListBox or ComboBox
"FindString", 'string' | Returns occurrence ref of the exact string in a ListBox or ComboBox
"SetCurrentSelection", occurrence | Sets selection to occurrence ref in a ListBox or ComboBox
"SelectString", 'string' | Sets selection according to string in a ListBox or ComboBox
"IsChecked", "" | Returns 1 if Button is checked, 0 otherwise
"Check", "" | Checks radio or check Button
"UnCheck", "" | Unchecks radio or check Button
"GetCurrentLine", "" | Returns the line # where the caret is in an Edit
"GetCurrentCol", "" | Returns the column # where the caret is in an Edit
"GetCurrentSelection", "" | Returns name of the currently selected item in a ListBox or ComboBox
"GetLineCount", "" | Returns # of lines in an Edit
"GetLine", line# | Returns text at line # passed of an Edit
"GetSelected", "" | Returns selected text of an Edit
"EditPaste", 'string' | Pastes the 'string' at the Edit's caret position
"CurrentTab", "" | Returns the current Tab shown of a SysTabControl32
"TabRight", "" | Moves to the next tab to the right of a SysTabControl32
"TabLeft", "" | Moves to the next tab to the left of a SysTabControl32

Remarks

Some controls will resist automation unless they are the active window. Use the WinActive() function to force the control's window to the top before using ControlCommand() on these controls.

Certain commands that work on normal Combo and ListBoxes do not work on "ComboLBox" controls.

Related

ControlClick, ControlDisable, ControlEnable, ControlFocus, ControlGetPos, ControlGetText, ControlHide, ControlClick, ControlMove, ControlSetText, ControlShow, StatusbarGetText, WinActivate, WinMenuSelectItem, WinGetClassList

Example

ControlCommand("Untitled - Notepad", "", "Edit1", "GetLineCount", "")


Function ControlDisable

Function Reference

ControlDisable

Disables or "grays-out" a control.

ControlDisable ( "title", "text", controlID)

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

None.

Related

ControlEnable, ControlHide, ControlCommand

Example

ControlDisable("Untitled -", "", "MDIClient1")


Function ControlEnable

Function Reference

ControlEnable

Enables a "grayed-out" control.

ControlEnable ( "title", "text", controlID )

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

None.

Related

ControlDisable, ControlShow, ControlCommand

Example

ControlEnable("Untitled -", "", "MDIClient1")


Function ControlFocus

Function Reference

ControlFocus

Sets input focus to a given control on a window.

ControlFocus ( "title", "text", controlID )

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

None.

Related

ControlCommand, WinActivate

Example

ControlFocus("Untitled - Notepad", "", "Edit1")


Function ControlGetHandle

Function Reference

ControlGetHandle

Retrieves the internal handle of a control.

ControlGetHandle ( "title", "text", controlID )

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.

Return Value

Success: | Returns the handle (HWND) value.
Failure: | Returns "" (blank string) and sets @error to 1 if no window matches the criteria.

Remarks

This function returns a HWND/Handle value.

Related

None.

Example

$handle = ControlGetHandle("Untitled - Notepad", "", "Edit1")


Function ControlGetPos

Function Reference

ControlGetPos

Retrieves the position and size of a control relative to it's window.

ControlGetPos ( "title", "text", controlID )

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.

Return Value

Success: | Returns an array containing the size and the control's position relative to it's client window:
 | $array[0] = X position
 | $array[1] = Y position
 | $array[2] = Width
 | $array[3] = Height
Failure: | Sets @error to 1.

Remarks

The title/text is referencing the parent window, so be careful with "","" which references the active window which may not be the one containing the controlID control.

Related

ControlCommand, ControlMove, WinMove

Example

$pos = ControlGetPos("Untitled - Notepad", "", "Edit1")
MsgBox(0, "Window Stats:", "POS: " & $pos[0] & "," & $pos[1] & " SIZE: " & $pos[2] & "," & $pos[3] )


Function ControlGetText

Function Reference

ControlGetText

Retrieves text from a control.

ControlGetText ( "title", "text", controlID )

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.

Return Value

Success: | Returns text from a control.
Failure: | Sets @error to 1 and returns a blank string of "".

Remarks

None.

Related

WinGetText, StatusbarGetText, ControlSetText, ControlCommand

Example

$var = ControlGetText("Untitled - Notepad", "", "Edit1")


Function ControlHide

Function Reference

ControlHide

Hides a control.

ControlHide ( "title", "text", controlID )

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if window/control is not found.

Remarks

None.

Related

ControlShow, ControlCommand, WinSetState

Example

ControlHide("Untitled -", "", "MDIClient1")


Function ControlMove

Function Reference

ControlMove

Moves a control within a window.

ControlMove ( "title", "text", controlID, x, y [, width [, height]] )

Parameters

title | The title of the window to move.
text | The text of the window to move.
controlID | The control to interact with. See Controls.
x | X coordinate to move to relative to the window client area.
y | Y coordinate to move to relative to the window client area.
width | [optional] New width of the window.
height | [optional] New height of the window.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if window/control is not found.

Remarks

If x and y equal to the Default keyword no move occurs, just resizing.

Related

ControlCommand, WinMove

Example

ControlMove("Untitled -", "", "MDIClient1", 0, 0, 200, 200)


Function ControlSend

Function Reference

ControlSend

Sends a string of characters to a control.

ControlSend ( "title", "text", controlID, "string" [, flag] )

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.
string | String of characters to send to the control.
flag | [optional] Changes how "keys" is processed: flag = 0 (default), Text contains special characters like + to indicate SHIFT and {LEFT} to indicate left arrow. flag = 1, keys are sent raw.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if window/control is not found.

Remarks

ControlSend works in a similar way to Send but it can send key strokes directly to a window/control, rather than just to the active window.

ControlSend is only unreliable for command prompts as that works differently to normal windows (seems to check physical states rather than accepting the keystroke messages). For normal windows ControlSend should be way more reliable than a normal Send - and yes it does send shift, ctrl, alt etc.

As mention in the Send help the keyboard that send different chars when in CAPS LOCK and using the Shift Key cannot be simulated. An example is the Czech Keyboard. A good workaround is to use the ControlSetText.

The control might first need to be given focus with the ControlFocus command, specially when referencing an controlID created by the script itself.

Opt("SendKeyDelay",...) alters the the length of the brief pause in between sent keystrokes.
Opt("SendKeyDownDelay",...) alters the length of time a key is held down before being released during a keystroke.

Related

ControlCommand, Send, ControlSetText, ControlFocus, SendKeyDelay (Option), SendKeyDownDelay (Option)

Example

ControlSend("Untitled", "", "Edit1", "This is a line of text in the notepad window")


Function ControlSetText

Function Reference

ControlSetText

Sets text of a control.

ControlSetText ( "title", "text", controlID, "new text" [, flag] )

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.
new text | The new text to be set into the control.
flag | [optional] when different from 0 (default) will force the target window to be redrawn.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if window/control is not found.

Remarks

None.

Related

ControlGetText, ControlCommand

Example

Run("notepad.exe")
WinWait("Untitled -")
ControlSetText("Untitled -", "", "Edit1", "New Text Here" )


Function ControlShow

Function Reference

ControlShow

Shows a control that was hidden.

ControlShow ( "title", "text", controlID )

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if window/control is not found.

Remarks

None.

Related

ControlHide, ControlEnable, ControlCommand

Example

ControlShow("Untitled -", "", "MDIClient1")


Function DllCall

Function Reference

DllCall

Dynamically calls a function in a DLL.

DllCall ( "dll", "return type", "function" [, "type1", param1 [, "type n", param n]] )

Parameters

dll | The filename of the DLL to use. e.g. "user32.dll". A handle obtained from DllOpen can also be used (See Remarks).
return type | The return type of the function (see below).
function | The name, eg. "MessageBox" or the ordinal value, e.g. 62, of the function in the DLL to call.
type | [optional] The type of the parameter (see remarks).
param | [optional] The actual parameter (see remarks).

Return Value

Success: | @error = 0.
Failure: | @error = 1 unable to use the DLL file,
 | @error = 2 unknown "return type",
 | @error = 3 "function" not found in the DLL file.
See remarks.

Remarks

If a dll filename is given then the DLL is automatically loaded and then closed at the end of the call. If you want to manually control the loading and unloading of the DLL then you should use DllOpen and DllClose and use a handle instead of a filename in this function.

By default, AutoIt uses the 'stdcall' calling method. To use the 'cdecl' method place ':cdecl' after the return type.
DllCall("SQLite.dll", "int:cdecl", "sqlite3_open", "str", $sDatabase_Filename , "long_ptr", 0).

You can have as many "types" and "param" as you like. See the examples below that use a number of parameters.

Valid Types are:

Type | Details
none | no value (only valid for return type - equivalent to void in C)
byte | a 8 bit integer
ubyte | an unsigned8 bit integer
short | a 16 bit integer
ushort | an unsigned 16 bit integer
dword | a 32 bit integer
udword | an unsigned 32 bit integer
int | a 32 bit integer
uint | an unsigned 32 bit integer
long | a 32 bit integer
short_ptr | a pointer to a 16 bit integer
int_ptr | a pointer to a 32 bit integer
long_ptr | a pointer to a 32 bit integer
str | a string (cannot be more than 65536)
wstr | a wide character string (converted to/from an ANSI string during the call). Cannot be more than 65536
hwnd | a window handle
ptr | a general pointer (void *)
float | a single precision floating point number

If the function call fails then @error is set to 1. Otherwise an array is returned that contains the function return value and a copy of all the parameters (including parameters that the function may have modified).
$return[0] = function return value
$return[1] = param1
$return[2] = param2
...
$return[n] = paramn

Related

DllOpen, DllClose

Example

; *******************************************************
; Example 1 - calling the MessageBox API directly
; *******************************************************

$result = DllCall("user32.dll", "int", "MessageBox", "hwnd", 0, "str", "Some text", "str", "Some title", "int", 0)

; *******************************************************
; Example 2 - calling a function that modifies parameters
; *******************************************************

$hwnd = WinGetHandle("Untitled - Notepad")
$result = DllCall("user32.dll", "int", "GetWindowText", "hwnd", $hwnd, "str", "", "int", 32768)
msgbox(0, "", $result[0]) ; number of chars returned
msgbox(0, "", $result[2]) ; Text returned in param 2

; *******************************************************
; Example 3 - Show the Windows PickIconDlg
; *******************************************************

$sFileName = @SystemDir & '\shell32.dll'

; Create a strcuture to store the icon index
$stIcon = DllStructCreate("int")

If @OSType = "WIN32_NT" Then
; Convert and store the filename as a wide char string
$nBuffersize = DllCall("kernel32.dll", "int", "MultiByteToWideChar", "int", 0, "int", 0x00000001, "str", $sFileName, "int", -1, "ptr", 0, "int", 0)
$stString = DLLStructCreate("byte[" & 2 * $nBuffersize[0] & "]")
DllCall("kernel32.dll", "int", "MultiByteToWideChar", "int", 0, "int", 0x00000001, "str", $sFileName, "int", -1, "ptr", DllStructGetPtr($stString), "int", $nBuffersize[0])
Else
; Win'9x
$stString = DLLStructCreate("char[260]")
DllStructSetData($stString, 1, $sFileName)
EndIf

; Run the PickIconDlg - '62' is the ordinal value for this function
DllCall("shell32.dll", "none", 62, "hwnd", 0, "ptr", DllStructGetPtr($stString), "int", DllStructGetSize($stString), "ptr", DllStructGetPtr($stIcon))

If @OSType = "WIN32_NT" Then
; Convert the new selected filename back from a wide char string
$nBuffersize = DllCall("kernel32.dll", "int", "WideCharToMultiByte", "int", 0, "int", 0x00000200, "ptr", DllStructGetPtr($stString), "int", -1, "ptr", 0, "int", 0, "ptr", 0, "ptr", 0)
$stFile = DLLStructCreate("char[" & $nBuffersize[0] & "]")
DllCall("kernel32.dll", "int", "WideCharToMultiByte", "int", 0, "int", 0x00000200, "ptr", DllStructGetPtr($stString), "int", -1, "ptr", DllStructGetPtr($stFile), "int", $nBuffersize[0], "ptr", 0, "ptr", 0)
$sFileName = DllStructGetData($stFile, 1)
Else
$sFileName = DllStructGetData($stString, 1)
EndIf

$nIconIndex = DllStructGetData($stIcon, 1)

; Show the new filename and icon index
Msgbox(0, "Info", "Last selected file: " & $sFileName & @LF & "Icon-Index: " & $nIconIndex)

$stBuffer = 0
$stFile = 0
$stIcon = 0


Function DllClose

Function Reference

DllClose

Closes a previously opened DLL.

DllClose ( dllhandle )

Parameters

dllhandle The handle of a dll, as returned by a previous call to DllOpen.

Return Value

None.

Remarks

If dllhandle is invalid, an AutoIt runtime error will be thrown, and the script will terminate!
Upon termination, AutoIt automatically closes any dlls it opened but calling DllClose is still a good idea.

Related

DllCall, DllOpen

Example

$dll = DllOpen("user32.dll")
$result = DllCall($dll, "int", "MessageBox", "hwnd", 0, "str", "Some text", "str", "Some title", "int", 0)
DllClose($dll)


Function DllOpen

Function Reference

DllOpen

Opens a DLL file for use in DllCall.

DllOpen ( "filename" )

Parameters

filename Filename of the DLL file to open.

Return Value

Success: | Returns a dll "handle" to be used with subsequent Dll functions.
Failure: | Returns -1 if error occurs.

Remarks

When finished working with a dll, call the DllClose function to close it. AutoIt normally closes all files upon termination, but explicitly calling DllClose is still a good idea.

Related

DllCall, DllClose

Example

$dll = DllOpen("user32.dll")
$result = DllCall($dll, "int", "MessageBox", "hwnd", 0, "str", "Some text", "str", "Some title", "int", 0)
DllClose($dll)


Function DllStructCreate

Function Reference

DllStructCreate

Creates a C/C++ style structure to be used in DllCall.

DllStructCreate ( "Struct" [,Pointer] )

Parameters

"Struct" | A string representing the structure to create (See Remarks).
Pointer | If supplied the struct will not allocate memory but use the pointer supplied.

Return Value

Success: | A variable for use with DllStruct calls.
Failure: | 0.
@Error: | 0 = No Error.
 | 1 = Variable passed to DllStructCreate was not a string.
 | 2 = There is an unknown Data Type in the string passed.
 | 3 = Failed to allocate the memory needed for the struct, or Pointer = 0.
 | 4 = Error allocating memory for the passed string.

Remarks

Each data type must be separated by a semi-colon ';'. Create arrays by adding '[size]' after the data type.
DllStructCreate("int;char[128]"). An elementname can be added similar C declaration DllStructCreate("int n;char buffer[128]"). This dataname can be used in place of the element in other DllStruct... functions.

Type | Details
byte | 8bit(1byte) signed char
ubyte | 8bit(1byte) unsigned char
char | 8bit(1byte) ASCII char
wchar | 16bit(2byte) Wide char
short | 16bit(2bytes) signed integer
ushort | 16bit(2bytes) unsigned integer
int | 32bit(4bytes) signed integer
long | 32bit(4bytes) signed integer
uint | 32bit(4bytes) unsigned integer
dword | 32bit(4bytes) signed integer
udword | 32bit(4bytes) unsigned integer
ptr | 32bit(4bytes) integer
hwnd | 32bit(4bytes) integer
float | 32bit(4bytes) floating point
double | 64bit(8bytes) floating point
int64 | 64bit(8bytes) signed integer
uint64 | 64bit(8bytes) unsigned integer

To release allocated memory just reset the returned variable to 0.

Related

DllCall, DllStructCreate, DllStructGetData, DllStructSetData, DllStructGetPtr

Example

;=========================================================
; Create the struct
; struct {
; int var1;
; unsigned char var2;
; unsigned int var3;
; char var4[128];
; }
;=========================================================
$str = "int var1;ubyte var2;uint var3;char var4[128]"
$a = DllStructCreate($str)
if @error Then
MsgBox(0,"","Error in DllStructCreate " & @error);
exit
endif

;=========================================================
; Set data in the struct
; struct.var1 = -1;
; struct.var2 = 255;
; struct.var3 = INT_MAX; -1 will be typecasted to (unsigned int)
; strcpy(struct.var4,"Hello");
; struct.var4[0] = 'h';
;=========================================================
DllStructSetData($a,"var1",-1)
DllStructSetData($a,"var2",255)
DllStructSetData($a,"var3",-1)
DllStructSetData($a,"var4","Hello")
DllStructSetData($a,"var4",Asc("h"),1)

;=========================================================
; Display info in the struct
;=========================================================
MsgBox(0,"DllStruct","Struct Size: " & DllStructGetSize($a) & @CRLF & _
"Struct pointer: " & DllStructGetPtr($a) & @CRLF & _
"Data:" & @CRLF & _
DllStructGetData($a,1) & @CRLF & _
DllStructGetData($a,2) & @CRLF & _
DllStructGetData($a,3) & @CRLF & _
DllStructGetData($a,4))

;=========================================================
; Free the memory allocated for the struct if needed
;=========================================================
$a=0


Function DllStructGetData

Function Reference

DllStructGetData

Returns the data of an element of the struct.

DllStructGetData ( Struct, Element [, index ] )

Parameters

Struct | The struct returned by DllStructCreate.
Element | Which element of the struct you want to access, starting at 1 or the elementname as defined in DllStructCreate.
index | If the element is an array, you need to specify which index to return, otherwise it returns index 1. The first element is 1.
*char[n], byte[n] and ubyte[n] return all element data when index is omitted.

Return Value

Success: | Data in the element of the struct.
Failure: | 0.
@Error: | 0 = No Error.
 | 1 = Struct not a correct struct returned by DllStructCreate.
 | 2 = Element value out of range.
 | 3 = index would be outside of the struct.
 | 4 = Element data type is unknown
 | 5 = index <= 0.

Remarks

When the element is char[n] and index is omitted the data returned is a String,
when the element is byte[n] or ubyte[n] and index is omitted the data returned is a binary type,
otherwise it always returns a number.

Related

DllCall, DllStructCreate, DllStructSetData

Example

$p = DllStructCreate("dword dwOSVersionInfoSize;dword dwMajorVersion;dword dwMinorVersion;dword dwBuildNumber;dword dwPlatformId;char szCSDVersion[128]")

;think of this as p->dwOSVersionInfoSize = sizeof(OSVERSIONINFO)
DllStructSetData($p, "dwOSVersionInfoSize", DllStructGetSize($p))

;make the DllCall
$ret = DllCall("kernel32.dll","int","GetVersionEx","ptr",DllStructGetPtr($p))

if Not $ret[0] Then
MsgBox(0,"DllCall Error","DllCall Failed")
exit
EndIf

;get the returned values
$major = DllStructGetData($p,"dwMajorVersion")
$minor = DllStructGetData($p,"dwMinorVersion")
$build = DllStructGetData($p,"dwBuildNumber")
$platform = DllStructGetData($p,"dwPlatformId")
$version = DllStructGetData($p,"szCSDVersion")

;free the struct
$p =0

msgbox(0,"","Major: " & $major & @CRLF & _
"Minor: " & $minor & @CRLF & _
"Build: " & $build & @CRLF & _
"Platform ID: " & $platform & @CRLF & _
"Version: " & $version)


Function DllStructGetPtr

Function Reference

DllStructGetPtr

Returns the pointer to the struct or an element in the struct.

DllStructGetPtr ( Struct [,Element])

Parameters

Struct | The struct returned by DllStructCreate.
Element | (Optional) The element of the struct who's pointer you need, starting at 1 or the elementname as defifined in DllStructCreate.

Return Value

Success: | The pointer to the struct.
Failure: | 0.
@Error: | 0 = No Error.
 | 1 = Struct not a correct struct returned by DllStructCreate.
 | 2 = Element is out of bounds.

Remarks

Used in DllCall.

Related

DllCall, DllStructCreate

Example

;example1
;get a window handle and use WinGetPos to get the windows' rectangle
$hwnd = WinGetHandle("")
$coor = WinGetPos($hwnd)

;create the struct
$rect = DllStructCreate("int;int;int;int")

;make the DllCall
DLLCall("user32.dll","int","GetWindowRect", _
"hwnd",$hwnd, _
"ptr",DllStructGetPtr($rect)) ; use DllStructGetPtr when calling DllCall

;get the returned rectangle
$l = DllStructGetData($rect,1)
$t = DllStructGetData($rect,2)
$r = DllStructGetData($rect,3)
$b = DllStructGetData($rect,4)

;free the struct
$rect = 0

;display the results of WinGetPos and the returned rectangle
MsgBox(0,"The Larry Test :)","WinGetPos(): (" & $coor[0] & "," & $coor[1] & _
") (" & $coor[2] + $coor[0] & "," & $coor[3] + $coor[1] & ")" & @CRLF & _
"GetWindowRect(): (" & $l & "," & $t & ") (" & $r & "," & $b & ")")

;example2
; DllStructGetPtr referencing an item
$a = DllStructCreate("int")
if @error Then
MsgBox(0,"","Error in DllStructCreate " & @error);
exit
endif

$b = DllStructCreate("uint",DllStructGetPtr($a,1))
if @error Then
MsgBox(0,"","Error in DllStructCreate " & @error);
exit
endif

$c = DllStructCreate("float",DllStructGetPtr($a,1))
if @error Then
MsgBox(0,"","Error in DllStructCreate " & @error);
exit
endif

;set the data
DllStructSetData($a,1,-1)

;=========================================================
; Display the different data types of the same data
;=========================================================
MsgBox(0,"DllStruct", _
"int: " & DllStructGetData($a,1) & @CRLF & _
"uint: " & DllStructGetData($b,1) & @CRLF & _
"float: " & DllStructGetData($c,1) & @CRLF & _
"")

; release memory allocated
$a = 0


Function DllStructSetData

Function Reference

DllStructSetData

Sets the data in of an element in the struct.

DllStructSetData ( Struct, Element, value [, index ] )

Parameters

Struct | The struct returned by DllStructCreate.
Element | Which element of the struct you want to access, starting at 1 or the elementname as defifined in DllStructCreate.
value | The new value to place in the struct.
index | If the element is an array, you need to specify which index to set, otherwise it sets index 1. The first element is 1.

Return Value

Success: | value, which is read back from the struct.
Failure: | 0.
@Error: | 0 = No Error.
 | 1 = Struct not a correct struct returned by DllStructCreate.
 | 2 = Element value out of range.
 | 3 = index would be outside of the struct.
 | 4 = Element data type is unknown
 | 5 = index <= 0.

Remarks

When the element is char[n], byte[n] or ubyte[n] the data can be a string otherwise it has to be a number.

Related

DllCall, DllStructCreate, DllStructGetData

Example

;=========================================================
; Create the struct
; struct {
; int var1;
; unsigned char var2;
; unsigned int var3;
; char var4[128];
; }
;=========================================================
$str = "int;ubyte;uint;char[128]"
$a = DllStructCreate($str)
if @error Then
MsgBox(0,"","Error in DllStructCreate " & @error);
exit
endif

;=========================================================
; Set data in the struct
; struct.var1 = -1;
; struct.var2 = 255;
; struct.var3 = INT_MAX; -1 will be typecasted to (unsigned int)
; strcpy(struct.var4,"Hello");
; struct.var4[0] = 'h';
;=========================================================
DllStructSetData($a,1,-1)
DllStructSetData($a,2,255)
DllStructSetData($a,3,-1)
DllStructSetData($a,4,"Hello")
DllStructSetData($a,4,Asc("h"),1)

;=========================================================
; Display info in the struct
;=========================================================
MsgBox(0,"DllStruct","Struct Size: " & DllStructGetSize($a) & @CRLF & _
"Struct pointer: " & DllStructGetPtr($a) & @CRLF & _
"Data:" & @CRLF & _
DllStructGetData($a,1) & @CRLF & _
DllStructGetData($a,2) & @CRLF & _
DllStructGetData($a,3) & @CRLF & _
DllStructGetData($a,4))

;=========================================================
; Free the memory allocated for the struct
;=========================================================
$a = 0


Function GUICreate

Function Reference

GUICreate

Create a GUI window.

GUICreate ( "title" [, width [, height [, left [, top [, style [, exStyle [, parent]]]]]]] )

Parameters

title | The title of the dialog box.
width | [optional] The width of the window.
height | [optional] The height of the window.
left | [optional] The left side of the dialog box. By default (-1), the window is centered. If defined, top must also be defined.
top | [optional] The top of the dialog box. Default (-1) is centered
style | [optional] defines the style of the window. See GUI Control Styles Appendix. Use -1 for the default style which includes a combination of $WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU styles. Some styles are always included: $WS_CLIPSIBLINGS, and $WS_SYSMENU if $WS_MAXIMIZEBOX or $WS_SIZEBOX is specified.
exStyle | [optional] defines the extended style of the window. See the Extended Style Table below. -1 is the default.
parent | [optional] The handle of another previously created window - this new window then becomes a child of that window.

Return Value

Success: | Returns a windows handle.
Failure: | Returns 0 if the window cannot be created and sets @error to 1.

Remarks

By default the dialog box is non sizable and non maximizable. So WS_SIZEBOX or WS_MAXIMIZEBOX can be used in the style parameter.
As defining only one style just set this style don't forget to combine it with default ones, i.e. just defining WS_SIZEBOX will not set WS_MINIMIZEBOX, WS_CAPTION, WS_POPUP, WS_SYSMENU. So the best method to define a resizeable window is to use WS_OVERLAPPEDWINDOW.
When using $WS_EX_MDICHILD the position is relative to client area of the parent window. With $WS_EX_LAYERED it is possible to have a transparent pic on a background pic defined in the parent window.

To combine styles with the default style use BitOr($GUI_SS_DEFAULT_GUI, newstyle,...).

Extended Style table
Extended Style | result
$WS_EX_ACCEPTFILES | Allow an edit or input control within the created GUI window to receive filenames via drag and drop. The control must have also the $GUI_DROPACCEPTED state set by GUICtrlSetState. for other controls the drag&drop info can be retrieved with @GUI_DRAGID, @GUI_DRAGFILE, @GUIDROPID.
$WS_EX_APPWINDOW | Forces a top-level window onto the taskbar when the window is visible.
$WS_EX_CLIENTEDGE | Specifies that a window has a border with a sunken edge.
$WS_EX_CONTEXTHELP | Includes a question mark in the title bar of the window. Cannot be used with the WS_MAXIMIZEBOX or WS_MINIMIZEBOX.
$WS_EX_DLGMODALFRAME | Creates a window that has a double border; the window can, optionally, be created with a title bar by specifying the WS_CAPTION style in the style parameter.
$WS_EX_MDICHILD | Create a child window included in its parent window (simulation not real MDI).
$WS_EX_OVERLAPPEDWINDOW | Combines the WS_EX_CLIENTEDGE and WS_EX_WINDOWEDGE styles.
$WS_EX_STATICEDGE | Creates a window with a three-dimensional border style intended to be used for items that do not accept user input.
$WS_EX_TOPMOST | Specifies that a window created with this style should be placed above all non-topmost windows and should stay above them, even when the window is deactivated.
$WS_EX_TRANSPARENT | The window appears transparent because the bits of underlying sibling windows have already been painted.
$WS_EX_TOOLWINDOW | Creates a tool window; that is, a window intended to be used as a floating toolbar. A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font. A tool window does not appear in the taskbar or in the dialog box that appears when the user presses ALT+TAB. If a tool window has a system menu, its icon is not displayed on the title bar. However, you can display the system menu by typing ALT+SPACE.
$WS_EX_WINDOWEDGE | Specifies that a window has a border with a raised edge.
$WS_EX_LAYERED | Creates a layered window. Note that this cannot be used for child windows.

To use the values specified above you must #include <GUIConstants.au3> in your script.

Note: The handle returned from this function is a real windows handle, which means it can be used in the same way as the result of WinGetHandle.

Related

GUISet..., GUICtrlCreate..., GUIGetMsg, GUIGetStyle, GUIDelete, WinGetHandle

Example

; example 1
#include <GUIConstants.au3>

GUICreate("My GUI") ; will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW) ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

; example 2
#include <GUIConstants.au3>

$gui=GUICreate("Background", 800, 300)
; background picture
$background = GUICtrlCreatePic ("demo-bg.jpg", 0, 0, 800, 300)
GUISetState(@SW_SHOW)

; transparent child window
$pic=GUICreate("", 14, 80, 0, 0,$WS_POPUP,$WS_EX_LAYERED+$WS_EX_MDICHILD,$gui)
; transparent pic
$basti_stay = GUICtrlCreatePic ("l_st.gif", 0, 0, 14, 80)
GUISetState(@SW_SHOW)

do
$msg = GUIGetMsg()

until $msg = $GUI_EVENT_CLOSE


Function GUICtrlCreateAvi

Function Reference

GUICtrlCreateAvi

Creates an AVI video control for the GUI.

GUICtrlCreateAvi ( filename, subfileid, left, top [, width [, height [, style [, exStyle]]]] )

Parameters

filename | The filename of the video. Only .avi files are supported.
subfileid | id of the subfile to be used. If the file only contains one video then use -1.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : $ACS_TRANSPARENT $ACS_TRANSPARENT is always used unless $ACS_NONTRANSPARENT is specified.
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To obtain the value of the control see GUICtrlRead.
To set or change information in the control see GUICtrlSet....

To start the video as soon as the control is created use the $ACS_AUTOPLAY style.
You can can start and stop the animation by setting the state to 1 or 0 with GUICtrlSetState. See example.

To combine styles with the default style use BitOr($GUI_SS_DEFAULT_AVI, newstyle,...).

Default resizing is $GUI_DOCKSIZE.

Related

GUICoordMode (option), GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>

GUICreate ("My GUI Animation",300,200)
$ani1 = GUICtrlCreateAvi (@SystemDir & "\shell32.dll",150, 50,10)

$buttonstart = GUICtrlCreateButton ("start",50,150,70,22)
$buttonstop = GUICtrlCreateButton ("stop",150,150,70,22)

GUISetState( )

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

Select
case $msg = $GUI_EVENT_CLOSE
ExitLoop

case $msg = $buttonstart
GUICtrlSetState ($ani1, 1)

case $msg = $buttonstop
GUICtrlSetState ($ani1, 0)

EndSelect
Wend


Function GUICtrlCreateButton

Function Reference

GUICtrlCreateButton

Creates a Button control for the GUI.

GUICtrlCreateButton ( "text", left, top [, width [, height [, style [, exStyle]]]] )

Parameters

text | The text of the button control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : none. forced styles : $WS_TABSTOP, $BS_NOTIFY
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To set or change information in the control see GUICtrlSet....

A Button control can display an icon or image by using the $BS_ICON or $BS_BITMAP style. Use GUICtrlSetImage to specify the picture to use.

To combine styles with the default style use BitOr($GUI_SS_DEFAULT_BUTTON, newstyle,...).

Default resizing is $GUI_DOCKSIZE

Related

GUICoordMode (Option), GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>

GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered

Opt("GUICoordMode",2)
$Button_1 = GUICtrlCreateButton ("Run Notepad", 10, 30, 100)
$Button_2 = GUICtrlCreateButton ( "Button Test", 0, -1)

GUISetState () ; will display an dialog box with 2 button

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Button_1
Run('Notepad.exe') ; Will Run/Open Notepad
Case $msg = $Button_2
MsgBox(0, 'Testing', 'Button 2 was pressed') ; Will demonstrate Button 2 being pressed
EndSelect
Wend


Function GUICtrlCreateCheckbox

Function Reference

GUICtrlCreateCheckbox

Creates a Checkbox control for the GUI.

GUICtrlCreateCheckbox ( "text", left, top [, width [, height [, style [, exStyle]]]] )

Parameters

text | The text of the control checkbox.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : $BS_AUTOCHECKBOX. forced styles : $WS_TABSTOP, and $BS_AUTOCHECKBOX if no checkbox style defined.
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To obtain the value of the control see GUICtrlRead.
To set or change information in the control see GUICtrlSet....

A Checkbox control can display an icon or image by using the $BS_ICON or $BS_BITMAP style. Use GUICtrlSetImage to specify the picture to use.

To combine styles with the default style use BitOr($GUI_SS_DEFAULT_CHECKBOX, newstyle,...).

Default resizing is $GUI_DOCKHEIGHT.

Related

GUICoordMode (Option), GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>

GUICreate("My GUI Checkbox") ; will create a dialog box that when displayed is centered

$checkCN = GUICtrlCreateCheckbox ("CHECKBOX 1", 10, 10, 120, 20)

GUISetState () ; will display an dialog box with 1 checkbox

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlCreateCombo

Function Reference

GUICtrlCreateCombo

Creates a ComboBox control for the GUI.

GUICtrlCreateCombo ( "text", left, top [, width [, height [, style [, exStyle]]]] )

Parameters

text | The text which will appear in the combo control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : $CBS_DROPDOWN, $CBS_AUTOHSCROLL, $WS_VSCROLL forced style : $WS_TABSTOP
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To obtain the value of the control see GUICtrlRead.
To set or change information in the control see GUICtrlSet....

Under Windows XP/2003 Windows will ajust the size of the opened combo. On other Windows versions you can define this size with the "height" parameter if the default value is not BIG enough to contain at least one line.

To combine styles with the default style use BitOr($GUI_SS_DEFAULT_COMBO, newstyle,...).

Default resizing is $GUI_DOCKHEIGHT.

Related

GUICoordMode (Option), GUICtrlSetData, GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>

GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered

GUICtrlCreateCombo ("item1", 10,10) ; create first item
GUICtrlSetData(-1,"item2|item3","item3") ; add other item snd set a new default

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlCreateContextMenu

Function Reference

GUICtrlCreateContextMenu

Creates a context menu for a control or entire GUI window.

GUICtrlCreateContextMenu ( [controlID] )

Parameters

controlID [optional] Control identifier as returned by GUICtrlCreate...

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

After creating the context menu main control with this function, each menu item can be created by using GUICtrlCreateMenuItem.
Sub-menus can be created using GUICtrlCreateMenu.

If you use no parameters or -1 in this function then the context menu that is created is associated with the entire GUI window rather than an individual control.

Only one context menu per control is possible. If you wish to create a new context menu one you have to delete the existing menu first.

Note: You can't create context menus for controls that already have system context menus, i.e. edit or input controls.

Related

GUICtrlCreateMenuItem, GUICtrlCreateMenu, GUICtrlGetHandle, GUICtrlSetState, GUICtrlDelete

Example

; ****************
; * First sample *
; ****************

#include <GUIConstants.au3>

;right click on gui to bring up context Menu.
;right click on the "ok" button to bring up a controll specific context menu.

GUICreate("My GUI Context Menu", 300, 200)

$contextmenu = GUICtrlCreateContextMenu ()

$button = GUICtrlCreateButton("OK", 100, 100, 70, 20)
$buttoncontext = GUICtrlCreateContextMenu($button)
$buttonitem = GUICtrlCreateMenuitem("About button", $buttoncontext)

$newsubmenu = GUICtrlCreateMenu ("new", $contextmenu)
$textitem = GUICtrlCreateMenuitem ("text", $newsubmenu)

$fileitem = GUICtrlCreateMenuitem ("Open", $contextmenu)
$saveitem = GUICtrlCreateMenuitem ("Save", $contextmenu)
GUICtrlCreateMenuitem ("", $contextmenu) ; separator

$infoitem = GUICtrlCreateMenuitem ("Info", $contextmenu)

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

Exit

; *****************
; * Second sample *
; *****************

#include <GUIConstants.au3>

$hGui = GUICreate("My GUI", 170, 40)

$OptionsBtn = GUICtrlCreateButton("&Options", 10, 10, 70, 20, $BS_FLAT)

; At first create a dummy control for the options and a contextmenu for it
$OptionsDummy = GUICtrlCreateDummy()
$OptionsContext = GUICtrlCreateContextMenu($OptionsDummy)
$OptionsCommon = GUICtrlCreateMenuItem("Common", $OptionsContext)
$OptionsFile = GUICtrlCreateMenuItem("File", $OptionsContext)
GUICtrlCreateMenuItem("", $OptionsContext)
$OptionsExit = GUICtrlCreateMenuItem("Exit", $OptionsContext)

$HelpBtn = GUICtrlCreateButton("&Help", 90, 10, 70, 20, $BS_FLAT)

; Create a dummy control and a contextmenu for the help too
$HelpDummy = GUICtrlCreateDummy()
$HelpContext = GUICtrlCreateContextMenu($HelpDummy)
$HelpWWW = GUICtrlCreateMenuItem("Website", $HelpContext)
GUICtrlCreateMenuItem("", $HelpContext)
$HelpAbout = GUICtrlCreateMenuItem("About...", $HelpContext)

GUISetState()

While 1
$Msg = GUIGetMsg()

Switch $Msg
Case $OptionsExit, $GUI_EVENT_CLOSE
ExitLoop

Case $OptionsBtn
ShowMenu($hGui, $Msg, $OptionsContext)

Case $HelpBtn
ShowMenu($hGui, $Msg, $HelpContext)

Case $HelpAbout
Msgbox(64, "About...", "GUICtrlGetHandle-Sample")
EndSwitch
WEnd

Exit

; Show a menu in a given GUI window which belongs to a given GUI ctrl
Func ShowMenu($hWnd, $CtrlID, $nContextID)
Local $hMenu = GUICtrlGetHandle($nContextID)

$arPos = ControlGetPos($hWnd, "", $CtrlID)

Local $x = $arPos[0]
Local $y = $arPos[1] + $arPos[3]

ClientToScreen($hWnd, $x, $y)
TrackPopupMenu($hWnd, $hMenu, $x, $y)
EndFunc

; Convert the client (GUI) coordinates to screen (desktop) coordinates
Func ClientToScreen($hWnd, ByRef $x, ByRef $y)
Local $stPoint = DllStructCreate("int;int")

DllStructSetData($stPoint, 1, $x)
DllStructSetData($stPoint, 2, $y)

DllCall("user32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", DllStructGetPtr($stPoint))

$x = DllStructGetData($stPoint, 1)
$y = DllStructGetData($stPoint, 2)
; release Struct not really needed as it is a local
$stPoint = 0
EndFunc

; Show at the given coordinates (x, y) the popup menu (hMenu) which belongs to a given GUI window (hWnd)
Func TrackPopupMenu($hWnd, $hMenu, $x, $y)
DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0)
EndFunc


Function GUICtrlCreateDate

Function Reference

GUICtrlCreateDate

Creates a date control for the GUI.

GUICtrlCreateDate ( "text", left, top [, width [, height [, style [, exStyle]]]] )

Parameters

text | The preselected date.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : $DTS_LONGDATEFORMAT forced style : $WS_TABSTOP
exStyle | [optional] Defines the extended style of the control. See Extended Style Table. default (-1) : WS_EX_CLIENTEDGE

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To obtain the value of the control see GUICtrlRead.
To set or change information in the control see GUICtrlSet....

To combine styles with the default style use BitOr($GUI_SS_DEFAULT_DATE, newstyle,...).

To Format the date/time see example 3 to understand how to use a GuiCtrlSendMsg with a $DTM_SETFORMAT.

Default resizing is $GUI_DOCKHEIGHT.

Related

GUICoordMode (Option), GUICtrlSetState, GUIGetMsg, GUICtrlRead

Example

; example1
#include <GUIConstants.au3>

GUICreate ( "My GUI get date", 200,200,800,200)
$date=GUICtrlCreateDate ("1953/04/25", 10,10,185,20 )
GUISetState ()

; Run the GUI until the dialog is closed
Do
$msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE

MsgBox(0,"Date",GUICtrlRead($date))
GUIDelete()

; example2
#include <GUIConstants.au3>

GUICreate("My GUI get time")
$n=GUICtrlCreateDate ( "", 20, 20, 100, 20, $DTS_TIMEFORMAT)
GUISetState ()

; Run the GUI until the dialog is closed
Do
$msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE

MsgBox(0,"Time", GUICtrlRead($n))
GUIDelete()

; example3
#include <GUIConstants.au3>

GUICreate ( "My GUI get date", 200,200,800,200)
$date = GUICtrlCreateDate ("1953/04/25", 10,10,185,20 )

; to select a specific default format
If @UNICODE Then
$DTM_SETFORMAT = 0x1032
Else
$DTM_SETFORMAT = 0x1005
Endif
$style = "yyyy/MM/dd HH:mm:s"
GuiCtrlSendMsg($date, $DTM_SETFORMAT, 0, $style)

GuiSetState()
While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd

MsgBox(0,"Time", GUICtrlRead($date))


Function GUICtrlCreateDummy

Function Reference

GUICtrlCreateDummy

Creates a Dummy control for the GUI.

GUICtrlCreateDummy ( )

Parameters

None.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

This control can receive messages through a GUICtrlSendToDummy call. The control will "notify" as normal and the value sent with GUISendToDummy can be read with GUICtrlRead.

Related

GUICtrlSendToDummy, GUICtrlSetOnEvent, GUICtrlRead, GUICtrlSetData

Example

#include <GUIConstants.au3>

GUICreate("GUICtrlCreateDummy",250,200, 100,200)
GUISetBkColor (0x00E0FFFF) ; will change background color

$user = GUICtrlCreateDummy()
$button = GUICtrlCreateButton ("event",75,170,70,20)
$cancel = GUICtrlCreateButton ("Cancel",150,170,70,20)
GUISetState()

Do
$msg = GUIGetMsg ()

Select
Case $msg = $button
GUICtrlSendToDummy($user)
Case $msg = $cancel
GUICtrlSendToDummy($user)
Case $msg = $user
; special action before closing
; ...
exit
EndSelect
Until $msg = $GUI_EVENT_CLOSE


Function GUICtrlCreateEdit

Function Reference

GUICtrlCreateEdit

Creates an Edit control for the GUI.

GUICtrlCreateEdit ( "text", left, top [, width [, height [, style [, exStyle]]]] )

Parameters

text | The text of the control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : $ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL forced styles : $ES_MULTILINE, $WS_TABSTOP only if not $ES_READONLY
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To obtain the value of the control see GUICtrlRead.
To set or change information in the control see GUICtrlSet....

To combine styles with the default style use BitOr($GUI_SS_DEFAULT_EDIT, newstyle,...).

If you want to drag & drop a filename onto this control just add the WS_EX_ACCEPTFILES extended style on the GUICreate() and set the state to $GUI_DROPACCEPTED.
Multiple selected files will be dropped as separate lines.

Default resizing is $GUI_DOCKAUTO size and position will occur.

Creating a RichEdit control is too complex so it will not be included as a basic control.
You have to use the GuiCtrlCreateObj. See the second example if you need to have a RichEdit control.

Related

GUICoordMode (Option), GUICtrlSetData, GUICtrlSetState, GUIGetMsg, GUICtrlRead

Example

#include <GUIConstants.au3>

GUICreate("My GUI edit") ; will create a dialog box that when displayed is centered

$myedit=GUICtrlCreateEdit ("First line"& @CRLF, 176,32,121,97,$ES_AUTOVSCROLL+$WS_VSCROLL)

GUISetState ()

; will be append dont' forget 3rd parameter
GUICtrlSetData ($myedit, "Second line",1)

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

; Rich edit control EXAMPLE using GUICtrlCreateObj

; Author: Kåre Johansson
; AutoIt Version: 3.1.1.55
; Description: Very Simple example: Embedding RICHTEXT object
; Needs: MSCOMCT2.OCX in system32 but it's probably already there
; Date: 3 jul 2005

#include <GUIConstants.au3>
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

$oRP = ObjCreate("RICHTEXT.RichtextCtrl.1")

GUICreate("Embedded RICHTEXT control Test", 320, 200, -1, -1,BitOr($WS_OVERLAPPEDWINDOW,$WS_CLIPSIBLINGS,$WS_CLIPCHILDREN))
$TagsPageC = GuiCtrlCreateLabel('Visit Tags Page', 5, 180, 100, 15, $SS_CENTER)
GuiCtrlSetFont($TagsPageC,9,400,4)
GuiCtrlSetColor($TagsPageC,0x0000ff)
GuiCtrlSetCursor($TagsPageC,0)
$AboutC = GUICtrlCreateButton('About',105,177,70,20)
$PrefsC = GUICtrlCreateButton('FontSize',175,177,70,20)
$StatC = GUICtrlCreateButton('Plain Style',245,177,70,20)

$GUIActiveX = GUICtrlCreateObj( $oRP, 10, 10 , 400 , 260 )
GUICtrlSetPos($GUIActiveX,10,10,300,160)

With $oRP; Object tag pool
.OLEDrag()
.Font = 'Arial'
.text = "Hello - Au3 supports ActiveX components like the RICHTEXT thanks to SvenP" & @CRLF & 'Try write some text and quit to reload'
;.FileName = @ScriptDir & '\RichText.rtf'
;.BackColor = 0xff00
EndWith

GUISetState ();Show GUI

While 1
$msg = GUIGetMsg()

Select
Case $msg = $GUI_EVENT_CLOSE
$oRP.SaveFile( @ScriptDir & "\RichText.rtf", 0 )
ExitLoop
Case $msg = $TagsPageC
Run(@ComSpec & ' /c start http://www.myplugins.info/guids/typeinfo/typeinfo.php?clsid={3B7C8860-D78F-101B-B9B5-04021C009402}','', @SW_HIDE)
Case $msg = $AboutC
$oRP.AboutBox()
Case $msg = $PrefsC
$oRP.SelFontSize = 12
Case $msg = $StatC
$oRP.SelBold = False
$oRP.SelItalic = False
$oRP.SelUnderline = False
$oRP.SelFontSize = 8
EndSelect
WEnd

Exit

Func MyErrFunc()

Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _
"err.description is: " & @TAB & $oMyError.description & @CRLF & _
"err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _
"err.number is: " & @TAB & hex($oMyError.number,8) & @CRLF & _
"err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _
"err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _
"err.source is: " & @TAB & $oMyError.source & @CRLF & _
"err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _
"err.helpcontext is: " & @TAB & $oMyError.helpcontext _
,5)
; Will automatically continue after 5 seconds

Local $err = $oMyError.number
If $err = 0 Then $err = -1

SetError($err) ; to check for after this function returns
Endfunc


Function GUICtrlCreateGroup

Function Reference

GUICtrlCreateGroup

Creates a Group control for the GUI.

GUICtrlCreateGroup ( "text", left, top [, width [, height [, style [, exStyle]]]] )

Parameters

text | The text of the control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : none. forced styles : $WS_GROUP, $BS_GROUPBOX.
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

A group control is the thin line you see around controls (usually only Radio button) that visually groups them together. Only one Radio button within a Group can be selected at once.
If you want to have multiple groups without the visible line then you must use GUIStartGroup() to group your Radio buttons.

Default resizing is $GUI_DOCKAUTO size and position will occur.

Related

GUICoordMode (Option), GUIStartGroup

Example

#include <GUIConstants.au3>

GUICreate("My GUI group") ; will create a dialog box that when displayed is centered

GUICtrlCreateGroup ("Group 1", 190, 60, 90, 140)
$radio_1 = GUICtrlCreateRadio ("Radio 1", 210, 90, 50, 20)
$radio_2 = GUICtrlCreateRadio ("Radio 2", 210, 110, 60, 50)
GUICtrlCreateGroup ("",-99,-99,1,1) ;close group

GUISetState () ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlCreateIcon

Function Reference

GUICtrlCreateIcon

Creates an Icon control for the GUI.

GUICtrlCreateIcon ( filename, iconName, left, top [, width [, height [, style [, exStyle]]]] )

Parameters

filename | filename of the icon to be loaded.
iconName | Icon name if the file contain multiple icon. Can be an ordinal name if negative number. Otherwise -1.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is 32).
height | [optional] The height of the control (default is 32).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : $SS_NOTIFY forced styles : $WS_TABSTOP, $SS_ICON
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To set or change information in the control see GUICtrlSet....

To update the icon after the dialog box is displayed use GUICtrlSetImage

iconID can reference the icon group number. Use a resource hacker to know the value.

To combine styles with the default style use BitOr($GUI_SS_DEFAULT_ICON, newstyle,...).

Default resizing is $GUI_DOCKSIZE.

Passing a positive number will reference the string equivalent icon name.
Passing a negative number causes 1-based "index" behaviour. Some Dll can have icon extracted just with negative numbers.

Related

GUICoordMode (Option), GUICtrlSetImage, GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>

;example1 ---------------------------
GUICreate(" My GUI Icons")

$icon = GUICtrlCreateIcon ("shell32.dll",10, 20,20)
$icon2 = GUICtrlCreateIcon ("explorer.icl",10, 20,80)
$icon3 = GUICtrlCreateIcon ("explorer.icl",6, 80,80)
$n1=GUICtrlCreateIcon (@windowsdir & "\cursors\horse.ani",-1, 20,120,32,32)
$n2=GUICtrlCreateIcon ("shell32.dll",7 ,20,160,32,32)
GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

; example2 ---------------------------
Opt("GUICoordMode",1)

GUICreate("My GUI icon Race", 350,74,-1,-1)
GUICtrlCreateLabel ("", 331,0,1,74,5)
$n1=GUICtrlCreateIcon (@windowsdir & "\cursors\dinosaur.ani", -1, 0,0,32,32)
$n2=GUICtrlCreateIcon ( @windowsdir & "\cursors\horse.ani", -1, 0,40,32,32)

GUISetState (@SW_SHOW)

Dim $a = 0, $b = 0
While ($a < 300) And ($b < 300)
$a = $a + int(Random(0,1)+0.5)
$b = $b + int(Random(0,1)+0.5)
GUICtrlSetPos($n1, $a,0)
GUICtrlSetPos($n2, $b,40)
Sleep(20)
WEnd
sleep(1000)


Function GUICtrlCreateInput

Function Reference

GUICtrlCreateInput

Creates an Input control for the GUI.

GUICtrlCreateInput ( "text", left, top [, width [, height [, style [, exStyle]]]] )

Parameters

text | The text of the control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : $ES_LEFT, $ES_AUTOHSCROLL forced styles : $WS_TABSTOP only if no $ES_READONLY. $ES_MULTILINE is always reset.
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To obtain the value of the control see GUICtrlRead.
To set or change information in the control see GUICtrlSet....

For defining an input control for entering passwords (input is hidden with an asterisk) use the $ES_PASSWORD style.

If you want to drag & drop a filename onto this control just add the WS_EX_ACCEPTFILES extended style on the GUICreate() and set the state to $GUI_DROPACCEPTED.
After multiple drag and drop files on this control, you can retrieve the files name which are separated by "|" with GuiCtrlRead.

Default resizing is $GUI_DOCKHEIGHT.

Related

GUICoordMode (Option), GUICtrlSet..., GUIGetMsg, GUICtrlRead

Example

#include <GUIConstants.au3>

GUICreate(" My GUI input acceptfile", 320,120, @DesktopWidth/2-160, @DesktopHeight/2-45, -1, 0x00000018); WS_EX_ACCEPTFILES
$file = GUICtrlCreateInput ( "", 10, 5, 300, 20)
GUICtrlSetState(-1,$GUI_DROPACCEPTED)
GUICtrlCreateInput ("", 10, 35, 300, 20) ; will not accept drag&drop files
$btn = GUICtrlCreateButton ("Ok", 40, 75, 60, 20)

GUISetState ()

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
$msg = GUIGetMsg()
Select
Case $msg = $btn
exitloop
EndSelect
Wend

MsgBox (4096, "drag drop file", GUICtrlRead($file))


Function GUICtrlCreateLabel

Function Reference

GUICtrlCreateLabel

Creates a static Label control for the GUI.

GUICtrlCreateLabel ( "text", left, top [, width [, height [, style [, exStyle]]]] )

Parameters

text | The text of the control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix.
 | default ( -1) : none. forced styles : $SS_NOTIFY, $SS_LEFT
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To set or change information in the control see GUICtrlSet....

To combine styles with the default style use BitOr($GUI_SS_DEFAULT_LABEL, newstyle,...).

Default resizing is $GUI_DOCKAUTO size and position will occur.

The extended style $GUI_WS_EX_PARENTDRAG can be used to allow the dragging of the parent window for windows that don't have a titlebar (no $WS_CAPTION style in GUICreate).

To set the background to transparent, use GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT).

Related

GUICoordMode (Option), GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>

GUICreate("My GUI") ; will create a dialog box that when displayed is centered

GUISetHelp("notepad") ; will run notepad if F1 is typed
Opt("GUICoordMode",2)

$widthCell=70
GUICtrlCreateLabel ("Line 1 Cell 1", 10, 30, $widthCell) ; first cell 70 width
GUICtrlCreateLabel ("Line 2 Cell 1", -1, 0) ; next line
GUICtrlCreateLabel ("Line 3 Cell 2", 0, 0) ; next line and next cell
GUICtrlCreateLabel ("Line 3 Cell 3", 0, -1) ; next cell same line
GUICtrlCreateLabel ("Line 4 Cell 1", -3*$widthcell, 0) ; next line Cell1

GUISetState () ; will display an empty dialog box

; Run the GUI until the dialog is closed
Do
$msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE


Function GUICtrlCreateList

Function Reference

GUICtrlCreateList

Creates a List control for the GUI.

GUICtrlCreateList ( "text", left, top [, width [, height [, style [, exStyle]]]] )

Parameters

text | The text of the control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : $LBS_SORT, $WS_BORDER, $WS_VSCROLL forced styles : $WS_TABSTOP, $LBS_NOTIFY
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To obtain the value of the control see GUICtrlRead.
To set or change information in the control see GUICtrlSet....

The different list entries that can be selected can be set with GUICtrlSetData

To limit horizontal scrolling use GUICtrlSetLimit

To combine styles with the default style use BitOr($GUI_SS_DEFAULT_LIST, newstyle,...).

Default resizing is $GUI_DOCKAUTO size and position will occur.

Related

GUICoordMode (Option), GUICtrlSetData, GUICtrlSetLimit, GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>

GLOBAL $MESSAGE = "The following buttons have been clicked"
GUICreate("My GUI list") ; will create a dialog box that when displayed is centered

$add=GUICtrlCreateButton ("Add", 64,32,75,25)
$clear=GUICtrlCreateButton ("Clear", 64,72,75,25)
$mylist=GUICtrlCreateList ("buttons that have been clicked", 176,32,121,97)
GUICtrlSetLimit(-1,200) ; to limit horizontal scrolling
GUICtrlSetData(-1,$MESSAGE)
$close=GUICtrlCreateButton ("my closing button", 64,160,175,25)

GUISetState ()

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
$msg = GUIGetMsg()

Select
case $msg = $add
GUICtrlSetData($mylist,"You clicked button No1|")
case $msg = $clear
GUICtrlSetData($mylist,"")
Case $msg = $close
MsgBox(0,"", "the closing button has been clicked",2)
Exit
EndSelect
Wend


Function GUICtrlCreateListView

Function Reference

GUICtrlCreateListView

Creates a ListView control for the GUI.

GUICtrlCreateListView ( "text", left, top [, width [, height [, style [, exStyle]]]] )

Parameters

text | definition of columns heading. Each of them are separated with Opt("GUIDataSeparatorChar").
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : $LVS_SHOWSELALWAYS, $LVS_SINGLESEL forced style : $LVS_REPORT
exStyle | [optional] Defines the extended style of the control. See Extended Style Table or ListView Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To add items to a ListView control use GUICtrlCreateListViewItem

The ListView will appear by default as in the Explorer view "Details" (LVS_REPORT style is forced).
You can control initial column size by padding blanks to the column heading definition. The column can be extend during the GUICtrlCreateListViewItem according to item size. Size of a column will be up to around 25 characters. No resizing will be done during an update by GUICtrlSetData.

To create a ListView with Icon-, SmallIcon- or List-style just use after creation:
GUICtrlSetStyle with the styles $LVS_ICON, $LVS_LIST or $LVS_SMALLICON.

Sorting the list by clicking the column name (as in Explorer) is not currently implemented.

To have the entire line visually selected use the extended style LVS_EX_FULLROWSELECT.

To combine styles with the default style use BitOr($GUI_SS_DEFAULT_LISTVIEW, newstyle,...).

The special flag $GUI_BKCOLOR_LV_ALTERNATE can be used with Listview control to give alternate background of the ListviewItems lines.
The odd lines will get the color set by GUICtrlSetBkColor of the Listview control.
The even lines will get the color set by GUICtrlSetBkColor of the ListviewItem control.

A listview control must have aleast one column.

Related

GUICtrlCreateListViewItem, GUICtrlRegisterListViewSort, GUICoordMode (Option), GUICtrlSetData, GUIGetMsg, GUIDataSeparatorChar (Option)

Example

#include <GUIConstants.au3>

GUICreate("listview items",220,250, 100,200,-1,$WS_EX_ACCEPTFILES)
GUISetBkColor (0x00E0FFFF) ; will change background color

$listview = GUICtrlCreateListView ("col1 |col2|col3 ",10,10,200,150);,$LVS_SORTDESCENDING)
$button = GUICtrlCreateButton ("Value?",75,170,70,20)
$item1=GUICtrlCreateListViewItem("item2|col22|col23",$listview)
$item2=GUICtrlCreateListViewItem("item1|col12|col13",$listview)
$item3=GUICtrlCreateListViewItem("item3|col32|col33",$listview)
$input1=GUICtrlCreateInput("",20,200, 150)
GUICtrlSetState(-1,$GUI_DROPACCEPTED) ; to allow drag and dropping
GUISetState()
GUICtrlSetData($item2,"ITEM1")
GUICtrlSetData($item3,"||COL33")
GUICtrlDelete($item1)

Do
$msg = GUIGetMsg ()

Select
Case $msg = $button
MsgBox(0,"listview item",GUICtrlRead(GUICtrlRead($listview)),2)
Case $msg = $listview
MsgBox(0,"listview", "clicked="& GUICtrlGetState($listview),2)
EndSelect
Until $msg = $GUI_EVENT_CLOSE


Function GUICtrlCreateListViewItem

Function Reference

GUICtrlCreateListViewItem

Creates a ListView item.

GUICtrlCreateListViewItem ( "text", listviewID )

Parameters

text | subitemtext separated with Opt("GUIDataSeparatorChar").
listviewID | controlID of the ListView control holding the item.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

This function creates the individual ListView items that can be selected. The items function as normal controls and can be set with GUICtrlSetData.
Items can be deleted as with any other control by using GUICtrlDelete.
ListView items can be dragged and drop into an Edit or Input control with a $GUI_DROPACCEPTED state.
See GUICtrlCreateListView about resizing of the column.

The special flag $GUI_BKCOLOR_LV_ALTERNATE can be used with Listview control to give alternate background of the ListviewItems lines.
The odd lines will get the color set by GUICtrlSetBkColor of the Listview control.
The even lines will get the color set by GUICtrlSetBkColor of the ListviewItem control.

Related

GUICtrlCreateListView, GUICtrlSetData, GUICtrlSetState, GUICtrlDelete, GUIGetMsg, GUICtrlRead, GUIDataSeparatorChar (Option)

Example

#include <GUIConstants.au3>

GUICreate("listview items",220,250, 100,200,-1,$WS_EX_ACCEPTFILES)
GUISetBkColor (0x00E0FFFF) ; will change background color

$listview = GuiCtrlCreateListView ("col1 |col2|col3 ",10,10,200,150);,$LVS_SORTDESCENDING)
$button = GuiCtrlCreateButton ("Value?",75,170,70,20)
$item1=GuiCtrlCreateListViewItem("item2|col22|col23",$listview)
$item2=GuiCtrlCreateListViewItem("............item1|col12|col13",$listview)
$item3=GuiCtrlCreateListViewItem("item3|col32|col33",$listview)
$input1=GuiCtrlCreateInput("",20,200, 150)
GuiCtrlSetState(-1,$GUI_DROPACCEPTED) ; to allow drag and dropping
GuiSetState()
GUICtrlSetData($item2,"|ITEM1")
GUICtrlSetData($item3,"||COL33")
GUICtrlDelete($item1)

Do
$msg = GuiGetMsg ()

Select
Case $msg = $button
MsgBox(0,"listview item",GUICtrlRead(GUICtrlRead($listview)),2)
Case $msg = $listview
MsgBox(0,"listview", "clicked="& GuiCtrlGetState($listview),2)
EndSelect
Until $msg = $GUI_EVENT_CLOSE


Function GUICtrlCreateMenu

Function Reference

GUICtrlCreateMenu

Creates a Menu control for the GUI.

GUICtrlCreateMenu ( "submenutext" [, menuID [, menuentry]] )

Parameters

submenutext | The submenu text.
menuID | [optional] If defined, allows you to create a submenu in the referenced menu. If equal -1 it refers to first level menu.
menuentry | [optional] Allows you to define the entry number to be created. The entries are numbered starting at 0.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To set or change information in the control see GUICtrlSet....

Related

GUICtrlSetState, GUIGetMsg, GUICtrlCreateMenuItem, GUICtrlGetHandle

Example

#include <GUIConstants.au3>

GUICreate("My GUI menu",300,200)

Global $defaultstatus = "Ready"
Global $status

$filemenu = GUICtrlCreateMenu ("&File")
$fileitem = GUICtrlCreateMenuitem ("Open",$filemenu)
GUICtrlSetState(-1,$GUI_DEFBUTTON)
$helpmenu = GUICtrlCreateMenu ("?")
$saveitem = GUICtrlCreateMenuitem ("Save",$filemenu)
GUICtrlSetState(-1,$GUI_DISABLE)
$infoitem = GUICtrlCreateMenuitem ("Info",$helpmenu)
$exititem = GUICtrlCreateMenuitem ("Exit",$filemenu)
$recentfilesmenu = GUICtrlCreateMenu ("Recent Files",$filemenu,1)

$separator1 = GUICtrlCreateMenuitem ("",$filemenu,2) ; create a separator line

$viewmenu = GUICtrlCreateMenu("View",-1,1) ; is created before "?" menu
$viewstatusitem = GUICtrlCreateMenuitem ("Statusbar",$viewmenu)
GUICtrlSetState(-1,$GUI_CHECKED)
$okbutton = GUICtrlCreateButton ("OK",50,130,70,20)
GUICtrlSetState(-1,$GUI_FOCUS)
$cancelbutton = GUICtrlCreateButton ("Cancel",180,130,70,20)

$statuslabel = GUICtrlCreateLabel ($defaultstatus,0,165,300,16,BitOr($SS_SIMPLE,$SS_SUNKEN))

GUISetState ()
While 1
$msg = GUIGetMsg()

If $msg = $fileitem Then
$file = FileOpenDialog("Choose file...",@TempDir,"All (*.*)")
If @error <> 1 Then GUICtrlCreateMenuitem ($file,$recentfilesmenu)
EndIf
If $msg = $viewstatusitem Then
If BitAnd(GUICtrlRead($viewstatusitem),$GUI_CHECKED) = $GUI_CHECKED Then
GUICtrlSetState($viewstatusitem,$GUI_UNCHECKED)
GUICtrlSetState($statuslabel,$GUI_HIDE)
Else
GUICtrlSetState($viewstatusitem,$GUI_CHECKED)
GUICtrlSetState($statuslabel,$GUI_SHOW)
EndIf
EndIf
If $msg = $GUI_EVENT_CLOSE Or $msg = $cancelbutton Or $msg = $exititem Then ExitLoop
If $msg = $infoitem Then Msgbox(0,"Info","Only a test...")
WEnd
GUIDelete()

Exit


Function GUICtrlCreateMenuItem

Function Reference

GUICtrlCreateMenuItem

Creates a MenuItem control for the GUI.

GUICtrlCreateMenuItem ( "text", menuID [, menuentry [, menuradioitem]] )

Parameters

text | The text of the control.
menuID | Allows you to create a submenu in the referenced menu. If equal -1 it refers to the first level menu.
menuentry | [optional] Allows you to define the entry number to be created. The entries are numbered starting at 0.
menuradioitem | [optional] 0 (default) = create a normal menuitem, 1 = create a menuradioitem

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To set or change information in the control see GUICtrlSet....

If the Text parameter is a "" then a separator line is created. GUICtrlSetState can be used as for other controls. See example.

Related

GUICtrlSet..., GUIGetMsg, GUICtrlCreateMenu, GUICtrlCreateContextMenu

Example

#include <GUIConstants.au3>

GUICreate("My GUI menu",300,200)

Global $defaultstatus = "Ready"
Global $status

$filemenu = GUICtrlCreateMenu ("&File")
$fileitem = GUICtrlCreateMenuitem ("Open",$filemenu)
GUICtrlSetState(-1,$GUI_DEFBUTTON)
$helpmenu = GUICtrlCreateMenu ("?")
$saveitem = GUICtrlCreateMenuitem ("Save",$filemenu)
GUICtrlSetState(-1,$GUI_DISABLE)
$infoitem = GUICtrlCreateMenuitem ("Info",$helpmenu)
$exititem = GUICtrlCreateMenuitem ("Exit",$filemenu)
$recentfilesmenu = GUICtrlCreateMenu ("Recent Files",$filemenu,1)

$separator1 = GUICtrlCreateMenuitem ("",$filemenu,2) ; create a separator line

$viewmenu = GUICtrlCreateMenu("View",-1,1) ; is created before "?" menu
$viewstatusitem = GUICtrlCreateMenuitem ("Statusbar",$viewmenu)
GUICtrlSetState(-1,$GUI_CHECKED)
$okbutton = GUICtrlCreateButton ("OK",50,130,70,20)
GUICtrlSetState(-1,$GUI_FOCUS)
$cancelbutton = GUICtrlCreateButton ("Cancel",180,130,70,20)

$statuslabel = GUICtrlCreateLabel ($defaultstatus,0,165,300,16,BitOr($SS_SIMPLE,$SS_SUNKEN))

GUISetState ()
While 1
$msg = GUIGetMsg()

If $msg = $fileitem Then
$file = FileOpenDialog("Choose file...",@TempDir,"All (*.*)")
If @error <> 1 Then GUICtrlCreateMenuitem ($file,$recentfilesmenu)
EndIf
If $msg = $viewstatusitem Then
If BitAnd(GUICtrlRead($viewstatusitem),$GUI_CHECKED) = $GUI_CHECKED Then
GUICtrlSetState($viewstatusitem,$GUI_UNCHECKED)
GUICtrlSetState($statuslabel,$GUI_HIDE)
Else
GUICtrlSetState($viewstatusitem,$GUI_CHECKED)
GUICtrlSetState($statuslabel,$GUI_SHOW)
EndIf
EndIf
If $msg = $GUI_EVENT_CLOSE Or $msg = $cancelbutton Or $msg = $exititem Then ExitLoop
If $msg = $infoitem Then Msgbox(0,"Info","Only a test...")
WEnd
GUIDelete()

Exit


Function GUICtrlCreateMonthCal

Function Reference

GUICtrlCreateMonthCal

Creates a month calendar control for the GUI.

GUICtrlCreateMonthCal ( "text", left, top [, width [, height [, style [, exStyle]]]] )

Parameters

text | The preselected date.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : none. forced style : $WS_TABSTOP
exStyle | [optional] Defines the extended style of the control. See Extended Style Table. default (-1) : WS_EX_CLIENTEDGE

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To obtain the value of the control see GUICtrlRead.

Default resizing is $GUI_DOCKSIZE.

Related

GUICoordMode (Option), GUIGetMsg, GUICtrlRead

Example

#include <GUIConstants.au3>
GUICreate( "Get date", 210,190)

$Date = GUICtrlCreateMonthCal ("1953/03/25",10, 10)
GUISetState()

; Run the GUI until the dialog is closed or timeout

Do
$msg = GUIGetMsg()
If $msg = $Date Then MsgBox(0,"debug","calendar clicked")
Until $msg = $GUI_EVENT_CLOSE

MsgBox(0, $msg, GUICtrlread($Date), 2)


Function GUICtrlCreateObj

Function Reference

GUICtrlCreateObj

Creates an ActiveX control in the GUI.

GUICtrlCreateObj ( $ObjectVar, left, top [, width [, height ]] )

Parameters

ObjectVar | A variable pointing to a previously opened object
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

This function attempts to embed an 'ActiveX Control' or a 'Document Object' inside the GUI.
Not every control can be embedded. They must at least support an 'IDispatch' interface.

'Document Objects' will only be visible if the Windows style $WS_CLIPCHILDREN has been used in GUICreate().

The GUI functions GUICtrlRead and GUICtrlSet have no effect on this control. The object can only be controlled using 'methods' or 'properties' on the $ObjectVar.

Related

ObjCreate, ObjGet, ObjEvent, IsObj

Example

#include <GUIConstants.au3>
; Simple example: Embedding an Internet Explorer Object inside an AutoIt GUI
;
; See also: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/internetexplorer.asp

$oIE = ObjCreate("Shell.Explorer.2")

; Create a simple GUI for our output
GUICreate ( "Embedded Web control Test", 640, 580,(@DesktopWidth-640)/2, (@DesktopHeight-580)/2, BitOr($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
$GUIActiveX = GUICtrlCreateObj ( $oIE, 10, 40 , 600 , 360 )
$GUI_Button_Back = GuiCtrlCreateButton ("Back", 10, 420, 100, 30)
$GUI_Button_Forward = GuiCtrlCreateButton ("Forward", 120, 420, 100, 30)
$GUI_Button_Home = GuiCtrlCreateButton ("Home", 230, 420, 100, 30)
$GUI_Button_Stop = GuiCtrlCreateButton ("Stop", 330, 420, 100, 30)

GUISetState () ;Show GUI

$oIE.navigate("http://www.autoitscript.com")

; Waiting for user to close the window
While 1
$msg = GUIGetMsg()

Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $GUI_Button_Home
$oIE.navigate("http://www.autoitscript.com")
Case $msg = $GUI_Button_Back
$oIE.GoBack
Case $msg = $GUI_Button_Forward
$oIE.GoForward
Case $msg = $GUI_Button_Stop
$oIE.Stop
EndSelect

Wend

GUIDelete ()

Exit


Function GUICtrlCreatePic

Function Reference

GUICtrlCreatePic

Creates a Picture control for the GUI.

GUICtrlCreatePic ( filename, left, top [, width [, height [, style [, exStyle]]]] )

Parameters

filename | filename of the picture to be loaded.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : $SS_NOTIFY forced style : $SS_BITMAP
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0 if picture cannot be created.

Remarks

To set or change information in the control see GUICtrlSet....

To update the picture after the dialog box is displayed just use GUICtrlSetImage

If you want to have a picture having the same size as the file content just use width=height=0.

To have a transparent picture it is needed to create the GUI window with WS_EX_LAYERED extended style. The left-top pixel will be used as the transparency color. If several pictures are created the last picture is defining the transparent color. See example 2.
Animated .gif are not supported.

To combine styles with the default style use BitOr($GUI_SS_DEFAULT_PIC, newstyle,...).

Default resizing is $GUI_DOCKSIZE.

If a picture is set as a background picture, as the other controls will overlap, it's important to disable the pic control : GuiCtrlSetState(-1,$GUI_DISABLE). This does not work with Tab control which behave differently. in this case you need to create the picture with the $WS_CLIPSIBLINGS style, some $GUI_ONTOP can still be necessary for the tab control.

The extended style $GUI_WS_EX_PARENTDRAG can be used to allow the dragging of the parent window for windows that don't have a titlebar (no $WS_CAPTION style in GUICreate).

The background is always set to transparent. GUICtrlSetBkColor() has not effect on pic control.

Related

GUICoordMode (Option), GUICtrlSetImage, GUICtrlSet..., GUIGetMsg

Example

;----- example 1 ----
#include <GUIConstants.au3>
GUICreate("My GUI picture",350,300,-1,-1,$WS_SIZEBOX+$WS_SYSMENU) ; will create a dialog box that when displayed is centered

GUISetBkColor (0xE0FFFF)
$n=GUICtrlCreatePic(@Systemdir & "\oobe\images\mslogo.jpg",50,50, 200,50)

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

GUISetState ()
; resize the control
$n=GUICtrlSetPos($n,50,50,200,100)
; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

;----- example 2
#include <GUIConstants.au3>

$gui=GUICreate("test transparentpic", 200, 100)
$pic=GUICreate("", 68, 71, 10, 10,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD),$gui)
GUICtrlCreatePic(@Systemdir & "\oobe\images\merlin.gif",0,0, 0,0)

GUISetState(@SW_SHOW,$pic)
GUISetState(@SW_SHOW,$gui)

HotKeySet("{ESC}", "main")
HotKeySet("{LEFT}", "left")
HotKeySet("{RIGHT}", "right")
HotKeySet("{DOWN}", "down")
HotKeySet("{UP}", "up")
$picPos = WinGetPos($pic)
$guiPos = WinGetPos($gui)

do
$msg = GUIGetMsg()
until $msg = $GUI_EVENT_CLOSE
Exit

Func main()
$guiPos = WinGetPos($gui)
WinMove($gui,"",$guiPos[0]+10,$guiPos[1]+10)
EndFunc

Func left ()
$picPos = WinGetPos($pic)
WinMove($pic,"",$picPos[0]-10,$picPos[1])
EndFunc

Func right()
$picPos = WinGetPos($pic)
WinMove($pic,"",$picPos[0]+10,$picPos[1])
EndFunc

Func down()
$picPos = WinGetPos($pic)
WinMove($pic,"",$picPos[0],$picPos[1]+10)
EndFunc

Func up()
$picPos = WinGetPos($pic)
WinMove($pic,"",$picPos[0],$picPos[1]-10)
EndFunc


Function GUICtrlCreateProgress

Function Reference

GUICtrlCreateProgress

Creates a Progress control for the GUI.

GUICtrlCreateProgress ( left, top [, width [, height [, style [, exStyle]]]] )

Parameters

left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix.
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To obtain the value of the control see GUICtrlRead.
To set or change information in the control see GUICtrlSet....

To update the bar position just use GUICtrlSetData.

To combine styles with the default style use BitOr($GUI_SS_DEFAULT_PROGRESS, newstyle,...).

Default resizing is $GUI_DOCKAUTO size and position will occur.

Related

GUICoordMode (Option), GUICtrlSetData, GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>

GUICreate("My GUI Progressbar",220,100, 100,200)
$progressbar1 = GUICtrlCreateProgress (10,10,200,20)
GUICtrlSetColor(-1,32250); not working with Windows XP Style
$progressbar2 = GUICtrlCreateProgress (10,40,200,20,$PBS_SMOOTH)
$button = GUICtrlCreateButton ("Start",75,70,70,20)
GUISetState ()

$wait = 20; wait 20ms for next progressstep
$s = 0; progressbar-saveposition
do
$msg = GUIGetMsg()
If $msg = $button Then
GUICtrlSetData ($button,"Stop")
For $i = $s To 100
If GUICtrlRead($progressbar1) = 50 Then Msgbox(0,"Info","The half is done...", 1)
$m = GUIGetMsg ()

If $m = -3 Then ExitLoop

If $m = $button Then
GUICtrlSetData ($button,"Next")
$s = $i;save the current bar-position to $s
ExitLoop
Else
$s=0
GUICtrlSetData ($progressbar1,$i)
GUICtrlSetData ($progressbar2,(100 - $i))
Sleep($wait)
EndIf
Next
if $i >100 then
; $s=0
GUICtrlSetData ($button,"Start")
endif
EndIf
until $msg = $GUI_EVENT_CLOSE


Function GUICtrlCreateRadio

Function Reference

GUICtrlCreateRadio

Creates a Radio button control for the GUI.

GUICtrlCreateRadio ( "text", left, top [, width [, height [, style [, exStyle]]]] )

Parameters

text | The text of the control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : none. forced styles : $BS_AUTORADIOBUTTON and $WS_TABSTOP if first radio in the group.
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To obtain the value of the control see GUICtrlRead.
To set or change information in the control see GUICtrlSet....

To combine styles with the default style use BitOr($GUI_SS_DEFAULT_RADIO, newstyle,...).

Default resizing is $GUI_DOCKHEIGHT.

Related

GUICoordMode (Option), GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>
GUICreate("My GUI radio") ; will create a dialog box that when displayed is centered

$radio1 = GUICtrlCreateRadio ("Radio 1", 10, 10, 120, 20)
$radio2 = GUICtrlCreateRadio ("Radio 2", 10, 40, 120, 20)
GUICtrlSetState ($radio2, $GUI_CHECKED)

GUISetState () ; will display an dialog box with 1 checkbox

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED
MsgBox(64, 'Info:', 'You clicked the Radio 1 and it is Checked.')
Case $msg = $radio2 And BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED
MsgBox(64, 'Info:', 'You clicked on Radio 2 and it is Checked.')
EndSelect
Wend


Function GUICtrlCreateSlider

Function Reference

GUICtrlCreateSlider

Creates a Slider control for the GUI.

GUICtrlCreateSlider ( left, top [, width [, height [, style [, exStyle]]]] )

Parameters

left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : $TBS_AUTOTICKS
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To obtain the value of the control see GUICtrlRead.
To set or change information in the control see GUICtrlSet....

To update the bar position just use GUICtrlSetData.
To set the min and max value use GUICtrlSetLimit.

To combine styles with the default style use BitOr($GUI_SS_DEFAULT_SLIDER, newstyle,...).

Default resizing is $GUI_DOCKAUTO size and position will occur.

Related

GUICoordMode (Option), GUICtrlSetData, GUICtrlSetLimit, GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>

GUICreate("slider",220,100, 100,200)
GUISetBkColor (0x00E0FFFF) ; will change background color

$slider1 = GUICtrlCreateSlider (10,10,200,20)
GUICtrlSetLimit(-1,200,0) ; change min/max value
$button = GUICtrlCreateButton ("Value?",75,70,70,20)
GUISetState()
GUICtrlSetData($slider1,45) ; set cursor

$start=TimerInit()
Do
$n = GUIGetMsg ()

If $n = $button Then
MsgBox(0,"slider1",GUICtrlRead($slider1),2)
$start=TimerInit()
EndIf
Until $n = $GUI_EVENT_CLOSE


Function GUICtrlCreateTab

Function Reference

GUICtrlCreateTab

Creates a Tab control for the GUI.

GUICtrlCreateTab ( left, top [, width [, height [, style [, exStyle]]]] )

Parameters

left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : none. forced styles : $WS_TABSTOP, $WS_CLIPSIBLINGS
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

This control is just a control in which the tabitem controls will be created and after the specific control related to a specific tabitem will be created with GUICtrlCreate... controls.

To set or change information in the control see GUICtrlSet....

To combine styles with the default style use BitOr($GUI_SS_DEFAULT_TAB, newstyle,...).

Default resizing is $GUI_DOCKSIZE.

ONLY one Tab control can be created by window. But a script can creates several windows having a tab in.

Related

GUICtrlCreateTabItem, GUICoordMode (Option), GUICtrlCreate..., GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>

GUICreate("My GUI Tab") ; will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab=GUICtrlCreateTab (10,10, 200,100)

$tab0=GUICtrlCreateTabitem ("tab0")
GUICtrlCreateLabel ("label0", 30,80,50,20)
$tab0OK=GUICtrlCreateButton ("OK0", 20,50,50,20)
$tab0input=GUICtrlCreateInput ("default", 80,50,70,20)

$tab1=GUICtrlCreateTabitem ( "tab----1")
GUICtrlCreateLabel ("label1", 30,80,50,20)
$tab1combo=GUICtrlCreateCombo ("", 20,50,60,120)
GUICtrlSetData(-1,"Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon
$tab1OK=GUICtrlCreateButton ("OK1", 80,50,50,20)

$tab2=GUICtrlCreateTabitem ("tab2")
GUICtrlSetState(-1,$GUI_SHOW) ; will be display first
GUICtrlCreateLabel ("label2", 30,80,50,20)
$tab2OK=GUICtrlCreateButton ("OK2", 140,50,50)

GUICtrlCreateTabitem ("") ; end tabitem definition

GUICtrlCreateLabel ("label3", 20,130,50,20)

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlCreateTabItem

Function Reference

GUICtrlCreateTabItem

Creates a TabItem control for the GUI.

GUICtrlCreateTabItem ( "text" )

Parameters

text The text of the control.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

For setting more information see GUICtrlSet....

To select a specific tab to be shown when the dialog box open just issue a GUICtrlSetState(-1,$GUI_SHOW) see example

To terminate the tab control just create a last "tabitem" control with a null text "". The "tabitem" control cannot be painted (too much code ...)

When advanced mode is used, GUICtrlRead($tab,1) will return the controlID instead of index of the clicked tab item.

To create a new control on an existing tabitem use GUISwitch($hWin,$tabitem) to select it and just create your new control. Don't forget to close your tabitem creation with GUICtrlCreateTabItem("").

Related

GUICtrlSetState, GUISwitch, GUIGetMsg, GUICtrlRead, GUIEventOptions (Option)

Example

#include <GUIConstants.au3>
GUICreate("My GUI Tab",250,150); will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab=GUICtrlCreateTab (10,10, 200,100)

$tab0=GUICtrlCreateTabitem ("tab0")
GUICtrlCreateLabel ("label0", 30,80,50,20)
$tab0OK=GUICtrlCreateButton ("OK0", 20,50,50,20)
$tab0input=GUICtrlCreateInput ("default", 80,50,70,20)

$tab1=GUICtrlCreateTabitem ( "tab----1")
GUICtrlCreateLabel ("label1", 30,80,50,20)
$tab1combo=GUICtrlCreateCombo ("", 20,50,60,120)
GUICtrlSetData(-1,"Trids|CyberSlug|Larry|Jon|Tylo", "Jon"); default Jon
$tab1OK=GUICtrlCreateButton ("OK1", 80,50,50,20)

$tab2=GUICtrlCreateTabitem ("tab2")
GUICtrlSetState(-1,$GUI_SHOW); will be display first
GUICtrlCreateLabel ("label2", 30,80,50,20)
$tab2OK=GUICtrlCreateButton ("OK2", 140,50,50)

GUICtrlCreateTabitem (""); end tabitem definition

GUICtrlCreateLabel ("Click on tab and see the title", 20,130,250,20)

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
if $msg = $tab then
; display the clicked tab
if GUICtrlread ($tab) = 0 then WinSetTitle("My GUI Tab","","My GUI Tab0")
if GUICtrlread ($tab) = 1 then WinSetTitle("My GUI Tab","","My GUI Tab1")
if GUICtrlread ($tab) = 2 then WinSetTitle("My GUI Tab","","My GUI Tab2")
EndIf
Wend


Function GUICtrlCreateTreeView

Function Reference

GUICtrlCreateTreeView

Creates a TreeView control for the GUI.

GUICtrlCreateTreeView ( left, top [, width [, height [, style [, exStyle]]]] )

Parameters

left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS forced style : $WS_TABSTOP
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To set or change information in the control see GUICtrlSet....

To combine styles with the default style use BitOr($GUI_SS_DEFAULT_TREEVIEW, newstyle,...).

Related

GUICtrlCreateTreeViewItem, GUICoordMode (Option), GUICtrlSet..., GUIGetMsg, GUICtrlRead

Example

#include <GUIConstants.au3>

GUICreate("My GUI with treeview", 350, 215)

$treeview = GUICtrlCreateTreeView(6, 6, 100, 150, BitOr($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$generalitem = GUICtrlCreateTreeViewitem("General", $treeview)
GUICtrlSetColor(-1, 0x0000C0)
$displayitem = GUICtrlCreateTreeViewitem("Display", $treeview)
GUICtrlSetColor(-1, 0x0000C0)
$aboutitem = GUICtrlCreateTreeViewitem("About", $generalitem)
$compitem = GUICtrlCreateTreeViewitem("Computer", $generalitem)
$useritem = GUICtrlCreateTreeViewitem("User", $generalitem)
$resitem = GUICtrlCreateTreeViewitem("Resolution", $displayitem)
$otheritem = GUICtrlCreateTreeViewitem("Other", $displayitem)

$startlabel = GUICtrlCreateLabel("TreeView Demo",190,90,100,20)
$aboutlabel = GUICtrlCreateLabel("This little scripts demonstates the using of a treeview-control.", 190, 70, 100, 60)
GUICtrlSetState(-1, $GUI_HIDE) ; Hides the "aboutlabel"-text during initialization
$compinfo = GUICtrlCreateLabel("Name:" & @TAB & @ComputerName & @LF & "OS:" & @TAB & @OSVersion & @LF & "SP:" & @TAB & @OSServicePack, 120, 30, 200, 80)
GUICtrlSetState(-1, $GUI_HIDE) ; Hides the "compinfo"-text during initialization

GUICtrlCreateLabel("", 0, 170, 350, 2, $SS_SUNKEN)
$togglebutton = GUICtrlCreateButton("&Toggle", 35, 185, 70, 20)
$infobutton = GUICtrlCreateButton("&Info", 105, 185, 70, 20)
$statebutton = GUICtrlCreateButton("Col./Exp.", 175, 185, 70, 20)
$cancelbutton = GUICtrlCreateButton("&Cancel", 245, 185, 70, 20)

GUICtrlSetState($generalitem, BitOr($GUI_EXPAND,$GUI_DEFBUTTON)) ; Expand the "General"-item and paint in bold
GUICtrlSetState($displayitem, BitOr($GUI_EXPAND,$GUI_DEFBUTTON)) ; Expand the "Display"-item and paint in bold

GUISetState ()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $cancelbutton Or $msg = $GUI_EVENT_CLOSE
ExitLoop

Case $msg = $togglebutton ; Toggle the bold painting
If BitAnd(GUICtrlRead($generalitem), $GUI_DEFBUTTON) Then
GUICtrlSetState($generalitem, 0)
GUICtrlSetState($displayitem, 0)
Else
GUICtrlSetState($generalitem, $GUI_DEFBUTTON)
GUICtrlSetState($displayitem, $GUI_DEFBUTTON)
EndIf

Case $msg = $infobutton
$item = GUICtrlRead($treeview) ; Get the controlID of the current selected treeview item
If $item = 0 Then
MsgBox(64, "TreeView Demo", "No item currently selected")
Else
$text = GUICtrlRead($item, 1) ; Get the text of the treeview item
If $text == "" Then
MsgBox(16, "Error", "Error while retrieving infos about item")
Else
MsgBox(64, "TreeView Demo", "Current item selected is: " & $text) ; $advmsg[0] contains the text and $advmsg[1] the state value of the treeview item
EndIf
EndIf

Case $msg = $statebutton
$item = GUICtrlRead($treeview)
If $item > 0 Then
$hItem = GUICtrlGetHandle($item)
GuiCtrlSendMsg($treeview, $TVM_EXPAND, $TVE_TOGGLE, $hItem)
EndIf

; The following items will hide the other labels (1st and 2nd parameter) and then show the 'own' labels (3rd and 4th parameter)
Case $msg = $generalitem
GUIChangeItems($aboutlabel, $compinfo, $startlabel, $startlabel)

Case $msg = $aboutitem
GUICtrlSetState ($compinfo, $GUI_HIDE)
GUIChangeItems($startlabel, $startlabel, $aboutlabel, $aboutlabel)

Case $msg = $compitem
GUIChangeItems($startlabel, $aboutlabel, $compinfo, $compinfo)
EndSelect
WEnd

GUIDelete()
Exit

Func GUIChangeItems($hidestart, $hideend, $showstart, $showend)
Local $idx

For $idx = $hidestart To $hideend
GUICtrlSetState ($idx, $GUI_HIDE)
Next
For $idx = $showstart To $showend
GUICtrlSetState ($idx, $GUI_SHOW)
Next
EndFunc


Function GUICtrlCreateTreeViewItem

Function Reference

GUICtrlCreateTreeViewItem

Creates a TreeViewItem control for the GUI.

GUICtrlCreateTreeViewItem ( "text", treeviewID )

Parameters

text | The text of the control.
treeviewID | treeview identifier as return by treeview or treeviewitem creation if subtree is created.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

For setting more information see GUICtrlSet....

To paint a treeview item in bold (to show as default) use GuiCtrlSetState($treeviewItem, $GUI_DEFBUTTON),
to turn off this behaviour use GUICtrlSetState() with another value but $GUI_DEFBUTTON, for instance GuiCtrlSetState($treeviewItem, 0).

To expand a treeview item use GuiCtrlSetState($treeviewItem, $GUI_EXPAND).

To select a specific treeview item use GuiCtrlSetState($treeviewItem, $GUI_FOCUS).

Related

GUICtrlCreateTreeView, GUICtrlSet..., GUIGetMsg, GUICtrlRead, GUICtrlGetHandle

Example

#include <GUIConstants.au3>

GUICreate("My GUI with treeview", 350, 215)

$treeview = GUICtrlCreateTreeView(6, 6, 100, 150, BitOr($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$generalitem = GUICtrlCreateTreeViewitem("General", $treeview)
GUICtrlSetColor(-1, 0x0000C0)
$displayitem = GUICtrlCreateTreeViewitem("Display", $treeview)
GUICtrlSetColor(-1, 0x0000C0)
$aboutitem = GUICtrlCreateTreeViewitem("About", $generalitem)
$compitem = GUICtrlCreateTreeViewitem("Computer", $generalitem)
$useritem = GUICtrlCreateTreeViewitem("User", $generalitem)
$resitem = GUICtrlCreateTreeViewitem("Resolution", $displayitem)
$otheritem = GUICtrlCreateTreeViewitem("Other", $displayitem)

$startlabel = GUICtrlCreateLabel("TreeView Demo",190,90,100,20)
$aboutlabel = GUICtrlCreateLabel("This little scripts demonstates the using of a treeview-control.", 190, 70, 100, 60)
GUICtrlSetState(-1, $GUI_HIDE) ; Hides the "aboutlabel"-text during initialization
$compinfo = GUICtrlCreateLabel("Name:" & @TAB & @ComputerName & @LF & "OS:" & @TAB & @OSVersion & @LF & "SP:" & @TAB & @OSServicePack, 120, 30, 200, 80)
GUICtrlSetState(-1, $GUI_HIDE) ; Hides the "compinfo"-text during initialization

GUICtrlCreateLabel("", 0, 170, 350, 2, $SS_SUNKEN)
$togglebutton = GUICtrlCreateButton("&Toggle", 35, 185, 70, 20)
$infobutton = GUICtrlCreateButton("&Info", 105, 185, 70, 20)
$statebutton = GUICtrlCreateButton("Col./Exp.", 175, 185, 70, 20)
$cancelbutton = GUICtrlCreateButton("&Cancel", 245, 185, 70, 20)

GUICtrlSetState($generalitem, BitOr($GUI_EXPAND,$GUI_DEFBUTTON)) ; Expand the "General"-item and paint in bold
GUICtrlSetState($displayitem, BitOr($GUI_EXPAND,$GUI_DEFBUTTON)) ; Expand the "Display"-item and paint in bold

GUISetState ()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $cancelbutton Or $msg = $GUI_EVENT_CLOSE
ExitLoop

Case $msg = $togglebutton ; Toggle the bold painting
If BitAnd(GUICtrlRead($generalitem), $GUI_DEFBUTTON) Then
GUICtrlSetState($generalitem, 0)
GUICtrlSetState($displayitem, 0)
Else
GUICtrlSetState($generalitem, $GUI_DEFBUTTON)
GUICtrlSetState($displayitem, $GUI_DEFBUTTON)
EndIf

Case $msg = $infobutton
$item = GUICtrlRead($treeview) ; Get the controlID of the current selected treeview item
If $item = 0 Then
MsgBox(64, "TreeView Demo", "No item currently selected")
Else
$text = GUICtrlRead($item, 1) ; Get the text of the treeview item
If $text == "" Then
MsgBox(16, "Error", "Error while retrieving infos about item")
Else
MsgBox(64, "TreeView Demo", "Current item selected is: " & $text)
EndIf
EndIf

Case $msg = $statebutton
$item = GUICtrlRead($treeview)
If $item > 0 Then
$hItem = GUICtrlGetHandle($item)
DllCall("user32.dll", "int", "SendMessage", "hwnd", GUICtrlGetHandle($treeview), "int", $TVM_EXPAND, "int", $TVE_TOGGLE, "hwnd", $hItem)
EndIf

; The following items will hide the other labels (1st and 2nd parameter) and then show the 'own' labels (3rd and 4th parameter)
Case $msg = $generalitem
GUIChangeItems($aboutlabel, $compinfo, $startlabel, $startlabel)

Case $msg = $aboutitem
GUICtrlSetState ($compinfo, $GUI_HIDE)
GUIChangeItems($startlabel, $startlabel, $aboutlabel, $aboutlabel)

Case $msg = $compitem
GUIChangeItems($startlabel, $aboutlabel, $compinfo, $compinfo)
EndSelect
WEnd

GUIDelete()
Exit

Func GUIChangeItems($hidestart, $hideend, $showstart, $showend)
Local $idx

For $idx = $hidestart To $hideend
GUICtrlSetState ($idx, $GUI_HIDE)
Next
For $idx = $showstart To $showend
GUICtrlSetState ($idx, $GUI_SHOW)
Next
EndFunc


Function GUICtrlCreateUpdown

Function Reference

GUICtrlCreateUpdown

Creates an UpDown control for the GUI.

GUICtrlCreateUpdown ( inputcontrolID [,style] )

Parameters

inputcontrolID | The controlID of the input control in which the updown control will be created.
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : $UDS_ALIGNRIGHT. forced style : $UDS_SETBUDDYINT and $UDS_ALIGNRIGHT if no align defined.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

Max and min value can be set with GUICtrlSetLimit.
By default Windows increases the value when clicking the upper arrow button.

Default height resizing is done according to the one of the related input control.

Related

GUICtrlCreateInput, GUICtrlSetData, GUICtrlSetLimit

Example

#include <GUIConstants.au3>

$title = "My GUI UpDown"
GUICreate($title,-1,-1,-1,-1, $WS_SIZEBOX)

$input = GUICtrlCreateInput ("2",10,10, 50, 20)
$updown = GUICtrlCreateUpdown($input)

; Attempt to resize input control
GUICtrlSetPos($input, 10,10, 100, 40 )

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

msgbox(0,"Updown",GUICtrlRead($input))


Function GUICtrlDelete

Function Reference

GUICtrlDelete

Deletes a control.

GUICtrlDelete ( controlID )

Parameters

controlID The control identifier (controlID) as returned by a GUICtrlCreate... function.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

For context menu controls see GUICtrlCreateContextMenu remarks.

Related

GUICreate, GUICtrlCreate..., GUICtrlCreateContextMenu

Example

#include <GUIConstants.au3>

GUICreate ( "My GUI delete control", 200,200,800,200)
$date=GUICtrlCreateDate ("1953/04/25", 10,10,185,20 )
$del=GUICtrlCreateButton("Delete control", 50,50,70,20 )
GUISetState ()

; Run the GUI until the dialog is closed
Do
$msg = GUIGetMsg()
if $msg = $del then
GUICtrlDelete($date)
GUICtrlDelete($del)
endif
Until $msg = $GUI_EVENT_CLOSE


Function GUICtrlGetHandle

Function Reference

GUICtrlGetHandle

Returns the handle for a control and some special (item) handles (Menu, ContextMenu, TreeViewItem).

GUICtrlGetHandle ( controlID )

Parameters

controlID Control identifier as returned by GUICtrlCreate...

Return Value

Success: | Returns the handle of the given control ID.
Failure: | Returns 0.

Remarks

! These controls are not supported: Dummy, Graphic, Object, ListViewItem and TabItem !

ListViewItems and TabItems are managed through indexes.
To get the index of these items use DllCall() and DllStructCreate().

Related

GUICtrlRead, GUICtrlGetState, IsHWnd

Example

#include <GUIConstants.au3>

Global Const $MIM_APPLYTOSUBMENUS = 0x80000000
Global Const $MIM_BACKGROUND = 0x00000002

$hGui = GUICreate("My GUI", 300, 200)

$FileMenu = GUICtrlCreateMenu("&File")
$OpenItem = GUICtrlCreateMenuItem("&Open", $FileMenu)
$SaveItem = GUICtrlCreateMenuItem("&Save", $FileMenu)
GUICtrlCreateMenuItem("", $FileMenu)

$OptionsMenu = GUICtrlCreateMenu("O&ptions", $FileMenu)
$ViewItem = GUICtrlCreateMenuItem("View", $OptionsMenu)
GUICtrlCreateMenuItem("", $OptionsMenu)
$ToolsItem = GUICtrlCreateMenuItem("Tools", $OptionsMenu)

GUICtrlCreateMenuItem("", $FileMenu)
$ExitItem = GUICtrlCreateMenuItem("&Exit", $FileMenu)

$HelpMenu = GUICtrlCreateMenu("&?")
$AboutItem = GUICtrlCreateMenuItem("&About", $HelpMenu)

$EndBtn = GUICtrlCreateButton("End", 110, 140, 70, 20)

SetMenuColor($FileMenu, 0xEEBB99) ; BGR color value
SetMenuColor($OptionsMenu, 0x66BB99); BGR color value
SetMenuColor($HelpMenu, 0x99BBEE) ; BGR color value

GUISetState()

While 1
$Msg = GUIGetMsg()

Switch $Msg
Case $EndBtn, $GUI_EVENT_CLOSE
ExitLoop

Case $AboutItem
Msgbox(64, "About...", "Colored menu sample")
EndSwitch
WEnd

Exit

; Apply the color to the menu
Func SetMenuColor($nMenuID, $nColor)
; Minimum OS are Windows98 and 2000
If @OSVersion = "WIN_95" Or @OSVersion = "WIN_NT4" Then Return

$hMenu = GUICtrlGetHandle($nMenuID)

$hBrush = DllCall("gdi32.dll", "hwnd", "CreateSolidBrush", "int", $nColor)
$hBrush = $hBrush[0]

Local $stMenuInfo = DllStructCreate("dword;dword;dword;uint;dword;dword;ptr")
DllStructSetData($stMenuInfo, 1, DllStructGetSize($stMenuInfo))
DllStructSetData($stMenuInfo, 2, BitOr($MIM_APPLYTOSUBMENUS, $MIM_BACKGROUND))
DllStructSetData($stMenuInfo, 5, $hBrush)

DllCall("user32.dll", "int", "SetMenuInfo", "hwnd", $hMenu, "ptr", DllStructGetPtr($stMenuInfo))

; release Struct not really needed as it is a local
$stMenuInfo = 0
EndFunc


Function GUICtrlGetState

Function Reference

GUICtrlGetState

Gets the current state of a control

GUICtrlGetState ( [controlID] )

Parameters

controlID [optional] The control identifier (controlID) as returned by a GUICtrlCreate... function.

Return Value

Success: | Returns the state. See GUICtrlSetState for values.
Failure: | Returns -1 if control is not defined.

Remarks

As opposed to GUICtrlRead this function returns only the state of a control enabled/disabled/hidden/show/dropaccepted

Exceptions:
For ListView controls it returns the number of the clicked column.

Related

GUICtrlRead, GUICtrlSetState

Example

#include <GUIConstants.au3>

GUICreate ("My GUI (GetControlState)")
$n=GUICtrlCreateCheckbox ("checkbox",10,10)
GUICtrlSetState (-1,1) ; checked

GUISetState () ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

msgbox (0,"state",StringFormat("GUICtrlRead=%d\nGUICtrlGetState=%d",GUICtrlRead($n),GUICtrlGetState($n)))


Function GUICtrlRead

Function Reference

GUICtrlRead

Read state or data of a control.

GUICtrlRead ( controlID [, advanced] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
advanced | [optional] returns extended information of a control. 0 = (Default) Returns a value with state or data of a control. 1 = Returns extended information of a control (see Remarks).

Return Value

Success: | Returns depending the control (see below).
Failure: | Returns 0.
Type | Value
Checkbox, Radio | state of the button. See State table
Combo, List | The value selected
Input, Edit | The text entered
Button | The display text
Date | The selected date
Progress | Current percentage
Slider | Current value
Tab | The number or the controlID of the tabitem selected depending of the advanced parameter value.
Menu, MenuItem | State of the menu/item. See State table
TreeView | Control identifier (controlID) of the selected TreeViewItem
TreeViewItem | State of the TreeViewItem
ListView | Control identifier (controlID) of the selected ListViewItem. 0 means no item is selected
Dummy | The value set by GUICtrlSendToDummy or GUICtrlSetData

Remarks

In 'advanced' mode the return value contains additional data of the control (see below).

Note: not for all known controls there is additional data available!

Type | Additional Value
Checkbox, Radio | The text of the control.
Menu, MenuItem | The text of the control.
TreeView | The text of the current selected TreeViewItem.
TreeViewItem | The text of the TreeViewItem.
ListViewItem | The state of the ListViewItem if $LVS_EX_CHECKBOXES exStyle used in advanced mode. See State table
Tab | The controlID of the tabitem selected

For Checkbox, Radio control several states can be returned as $GUI_FOCUS and $GUI_CHECKED,. So use i.e. BitAnd(GUICtrlRead($Item),$GUI_CHECKED) to test if the control is checked.

For Listview items several states can be returned as $GUI_CHECKED and $GUI_UNCHECKED (only for listview controls with LVS_EX_CHECKBOXES-exstyle and on 'advanced' return) . So use i.e. BitAnd(GUICtrlRead($Item),$GUI_CHECKED) to test if the item is checked.

For Treeview items several states can be returned as $GUI_FOCUS, $GUI_EXPAND and $GUI_CHECKED, $GUI_UNCHECKED (only for treeview controls with TVS_CHECKBOXES-style . So use i.e. BitAnd(GUICtrlRead($Item),$GUI_CHECKED) to test if the item is checked.

Related

GUICtrlSet..., GUIGetMsg, GUIEventOptions (Option)

Example

#include <GUIConstants.au3>

GUICreate("My GUICtrlRead") ; will create a dialog box that when displayed is centered

$menu1 = GUICtrlCreateMenu("File")

$n1 = GUICtrlCreateList("", 10, 10, -1, 100)
GUICtrlSetData(-1, "item1|item2|item3", "item2")

$n2 = GUICtrlCreateButton("Read", 10, 100, 50)
GUICtrlSetState(-1, $GUI_FOCUS) ; the focus is on this button

GUISetState () ; will display an empty dialog box
; Run the GUI until the dialog is closed
Do
$msg = GUIGetMsg()
if $msg = $n2 Then
Msgbox(0, "Selected listbox entry", GUICtrlRead($n1)) ; display the selected listbox entry
$menustate = GUICtrlRead($menu1) ; return the state of the menu item
$menutext = GUICtrlRead($menu1, 1) ; return the text of the menu item
Msgbox(0, "State and text of the menuitem", "state:" & $menustate & @LF & "text:" & $menutext)
EndIf
Until $msg = $GUI_EVENT_CLOSE


Function GUICtrlRecvMsg

Function Reference

GUICtrlRecvMsg

Send a message to a control and retrieve information in lParam.

GUICtrlRecvMsg ( controlID , msg [, wParam [, lParamType]] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
msg | type of message to be send to the control as defined in the Windows controls documentation.
wParam | [optional] An integer first param to be send to the control.
lParamType | [optional] Define the type of lParam that will be returned: 0 (default) for wParam and lParam, 1 for lParam String, 2 for lParam RECT struct.

Return Value

Success: | Returns the value returned by the SendMessage Windows API.
Failure: | Returns 0.

Remarks

This function allows the sending of special Windows messages directly to the control using the SendMessage API. It is used to enable special control features not available with the simple GUICtrlRead() and GUICtrlSet...() range of functions.

If the wParam and lParamType parameters are not specified then an array of two elements is returned (LPwParam, LPlParam).

The RECT is returned in an array of 4 elements (Left, Top, Right, Bottom).

Related

GUICtrlSendMsg, GUICtrlSet..., GUIGetMsg, GUICtrlRead

Example

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>

GUICreate("My GUI") ; will create a dialog box that when displayed is centered

$nEdit = GUICtrlCreateEdit ("line 0", 10,10)
GUICtrlCreateButton ("Ok", 20,200,50)

GUISetState ()

For $n=1 To 5
GUICtrlSetData ($nEdit, @CRLF & "line "& $n)
Next

; Run the GUI until the dialog is closed
Do
$msg = GUIGetMsg()
If $msg >0 Then
$a=GUICtrlRecvMsg($nEdit, $EM_GETSEL)
GUICtrlSetState($nEdit,$GUI_FOCUS) ; set focus back on edit control

; will display the wParam and lParam values return by the control
MsgBox(0,"Current selection",StringFormat("start=%d end=%d", $a[0], $a[1]))
EndIf
Until $msg = $GUI_EVENT_CLOSE


Function GUICtrlRegisterListViewSort

Function Reference

GUICtrlRegisterListViewSort

Register a user defined function for an internal listview sorting callback function.

GUICtrlRegisterListViewSort ( controlID, "function" )

Parameters

controlID | The listview controlID for which the user function should proceed.
function | The name of the user function to call when the sorting callback runs.

Return Value

Success: | 1
Failure: | 0

Remarks

!!! To make the user function workable you have to define it with maximum 4 function parameters otherwise the function won't be called !!!
i.e:
Func MySortFunction($nListViewID, $LParam1, $LParam2, $nColumn)
...
EndFunc

Or

Func MySortFunction($nListViewID, $LParam1, $LParam2)
...
EndFunc

When the user function is called then these 4 parameters have the following values:
Position | Parameter | Meaning
1 | controlID | The controlID of the listview control for which the callback function is used.
2 | lParam1 | The lParam value of the first item (by default the item controlID).
3 | lParam2 | The lParam value of the second item (by default the item controlID).
4 | column | The column that was clicked for sorting (the first column number is 0).

The following values have to be Returned to change the behaviour of the sorting callback:
Return value | Meaning
-1 | 1st item should precede the 2nd.
0 | No Change.
1 | 1st item should follow the 2nd.

See also examples for sorting with selfcreated GUI listview items.

Related

GUICtrlCreateListView

Example

; *******************************************************
; Example 1 - sorting 3 column's different
; *******************************************************

#include <GUIConstants.au3>

;Global Const $LVFI_PARAM = 0x0001
;Global Const $LVIF_TEXT = 0x0001
;Global Const $LVM_FIRST = 0x1000
;Global Const $LVM_GETITEM = $LVM_FIRST + 5
;Global Const $LVM_FINDITEM = $LVM_FIRST + 13
;Global Const $LVM_SETSELECTEDCOLUMN= $LVM_FIRST + 140

Dim $nCurCol = -1
Dim $nSortDir = 1
Dim $bSet = 0
Dim $nCol = -1

$hGUI = GUICreate("Test", 300, 200)

$lv = GUICtrlCreateListView("Column1|Col2|Col3", 10, 10, 280, 180)
GUICtrlRegisterListViewSort(-1, "LVSort") ; Register the function "SortLV" for the sorting callback

$lvi1 = GUICtrlCreateListViewItem("ABC|666|10.05.2004", $lv)
GUICtrlSetImage(-1, "shell32.dll", 7)
$lvi2 = GUICtrlCreateListViewItem("DEF|444|11.05.2005", $lv)
GUICtrlSetImage(-1, "shell32.dll", 12)
$lvi3 = GUICtrlCreateListViewItem("CDE|444|12.05.2004", $lv)
GUICtrlSetImage(-1, "shell32.dll", 3)

GUISetState()

While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
ExitLoop

Case $lv
$bSet = 0
$nCurCol = $nCol
GUICtrlSendMsg($lv, $LVM_SETSELECTEDCOLUMN, GUICtrlGetState($lv), 0)
DllCall("user32.dll", "int", "InvalidateRect", "hwnd", GUICtrlGetHandle($lv), "int", 0, "int", 1)
EndSwitch
WEnd

Exit

; Our sorting callback funtion
Func LVSort($hWnd, $nItem1, $nItem2, $nColumn)
Local $nSort

; Switch the sorting direction
If $nColumn = $nCurCol Then
If Not $bSet Then
$nSortDir = $nSortDir * -1
$bSet = 1
EndIf
Else
$nSortDir = 1
EndIf
$nCol = $nColumn

$val1 = GetSubItemText($lv, $nItem1, $nColumn)
$val2 = GetSubItemText($lv, $nItem2, $nColumn)

; If it is the 3rd colum (column starts with 0) then compare the dates
If $nColumn = 2 Then
$val1 = StringRight($val1, 4) & StringMid($val1, 4, 2) & StringLeft($val1, 2)
$val2 = StringRight($val2, 4) & StringMid($val2, 4, 2) & StringLeft($val2, 2)
EndIf

$nResult = 0 ; No change of item1 and item2 positions

If $val1 < $val2 Then
$nResult = -1 ; Put item2 before item1
ElseIf $val1 > $val2 Then
$nResult = 1 ; Put item2 behind item1
EndIf

$nResult = $nResult * $nSortDir

Return $nResult
EndFunc

; Retrieve the text of a listview item in a specified column
Func GetSubItemText($nCtrlID, $nItemID, $nColumn)
Local $stLvfi = DllStructCreate("uint;ptr;int;int[2];int")
DllStructSetData($stLvfi, 1, $LVFI_PARAM)
DllStructSetData($stLvfi, 3, $nItemID)

Local $stBuffer = DllStructCreate("char[260]")

$nIndex = GUICtrlSendMsg($nCtrlID, $LVM_FINDITEM, -1, DllStructGetPtr($stLvfi));

Local $stLvi = DllStructCreate("uint;int;int;uint;uint;ptr;int;int;int;int")

DllStructSetData($stLvi, 1, $LVIF_TEXT)
DllStructSetData($stLvi, 2, $nIndex)
DllStructSetData($stLvi, 3, $nColumn)
DllStructSetData($stLvi, 6, DllStructGetPtr($stBuffer))
DllStructSetData($stLvi, 7, 260)

GUICtrlSendMsg($nCtrlID, $LVM_GETITEM, 0, DllStructGetPtr($stLvi));

$sItemText = DllStructGetData($stBuffer, 1)

$stLvi = 0
$stLvfi = 0
$stBuffer = 0

Return $sItemText
EndFunc

; *******************************************************
; Example 2 - sorting with selfcreated items by DllCall
; *******************************************************

#include <GUIConstants.au3>

;Global Const $LVFI_PARAM = 0x0001

;Global Const $LVIF_TEXT = 0x0001
Global Const $LVIF_PARAM = 0x0004 ; Important for finding/sorting listview item

;Global Const $LVM_FIRST = 0x1000
;Global Const $LVM_GETITEMCOUNT = $LVM_FIRST + 4
Global Const $LVM_GETITEM = $LVM_FIRST + 5
Global Const $LVM_INSERTITEM = $LVM_FIRST + 7
;Global Const $LVM_FINDITEM = $LVM_FIRST + 13
;Global Const $LVM_SETCOLUMNWIDTH = $LVM_FIRST + 30
Global Const $LVM_SETITEMTEXT = $LVM_FIRST + 46
;Global Const $LVM_SETSELECTEDCOLUMN = $LVM_FIRST + 140

Dim $nCurCol = -1
Dim $nSortDir = 1
Dim $bSet = 0
Dim $nCol = -1

$hGUI = GUICreate("Test", 300, 200)

$lv = GUICtrlCreateListView("Column1|Col2|Col3", 10, 10, 280, 180)
GUICtrlRegisterListViewSort(-1, "LVSort") ; Register the function "SortLV" for the sorting callback

MyGUICtrlCreateListViewItem("ABC|666|10.05.2004", $lv, -1)
MyGUICtrlCreateListViewItem("DEF|444|11.05.2005", $lv, -1)
MyGUICtrlCreateListViewItem("CDE|444|12.05.2004", $lv, -1)

GUISetState()

While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
ExitLoop

Case $lv
$bSet = 0
$nCurCol = $nCol
GUICtrlSendMsg($lv, $LVM_SETSELECTEDCOLUMN, GUICtrlGetState($lv), 0)
DllCall("user32.dll", "int", "InvalidateRect", "hwnd", ControlGetHandle($hGUI, "", $lv), "int", 0, "int", 1)
EndSwitch
WEnd

Exit

; Our sorting callback funtion
Func LVSort($hWnd, $nItem1, $nItem2, $nColumn)
Local $nSort

; Switch the sorting direction
If $nColumn = $nCurCol Then
If Not $bSet Then
$nSortDir = $nSortDir * -1
$bSet = 1
EndIf
Else
$nSortDir = 1
EndIf
$nCol = $nColumn

$val1 = GetSubItemText($lv, $nItem1, $nColumn)
$val2 = GetSubItemText($lv, $nItem2, $nColumn)

; If it is the 3rd colum (column starts with 0) then compare the dates
If $nColumn = 2 Then
$val1 = StringRight($val1, 4) & StringMid($val1, 4, 2) & StringLeft($val1, 2)
$val2 = StringRight($val2, 4) & StringMid($val2, 4, 2) & StringLeft($val2, 2)
EndIf

$nResult = 0 ; No change of item1 and item2 positions

If $val1 < $val2 Then
$nResult = -1 ; Put item2 before item1
ElseIf $val1 > $val2 Then
$nResult = 1 ; Put item2 behind item1
EndIf

$nResult = $nResult * $nSortDir

Return $nResult
EndFunc

; Retrieve the text of a listview item in a specified column
Func GetSubItemText($nCtrlID, $nItemID, $nColumn)
Local $stLvfi = DllStructCreate("uint;ptr;int;int[2];int")
DllStructSetData($stLvfi, 1, $LVFI_PARAM) ; Find the item by our saved index
DllStructSetData($stLvfi, 3, $nItemID)

Local $stBuffer = DllStructCreate("char[260]")

$nIndex = GUICtrlSendMsg($nCtrlID, $LVM_FINDITEM, -1, DllStructGetPtr($stLvfi));

Local $stLvi = DllStructCreate("uint;int;int;uint;uint;ptr;int;int;int;int")

DllStructSetData($stLvi, 1, $LVIF_TEXT)
DllStructSetData($stLvi, 2, $nIndex)
DllStructSetData($stLvi, 3, $nColumn)
DllStructSetData($stLvi, 6, DllStructGetPtr($stBuffer))
DllStructSetData($stLvi, 7, 260)

GUICtrlSendMsg($nCtrlID, $LVM_GETITEM, 0, DllStructGetPtr($stLvi));

$sItemText = DllStructGetData($stBuffer, 1)

$stLvi = 0
$stLvfi = 0
$stBuffer = 0

Return $sItemText
EndFunc

; Create and insert items directly into the listview
Func MyGUICtrlCreateListViewItem($sText, $nCtrlID, $nIndex)
Local $stLvItem = DllStructCreate("uint;int;int;uint;uint;ptr;int;int;int;int;")
Local $stText = DllStructCreate("char[260]")
Local $arText = StringSplit($sText, "|")

If $nIndex = -1 Then $nIndex = GUICtrlSendMsg($nCtrlID, $LVM_GETITEMCOUNT, 0, 0)

DllStructSetData($stText, 1, $arText[1]) ; Save the item text in the struct

DllStructSetData($stLvItem, 1, BitOr($LVIF_TEXT, $LVIF_PARAM))
DllStructSetData($stLvItem, 2, $nIndex)
DllStructSetData($stLvItem, 6, DllStructGetPtr($stText))
; Set the lParam of the struct to the line index - unique within the listview
DllStructSetData($stLvItem, 9, $nIndex)

$nIndex = GUICtrlSendMsg($nCtrlID, $LVM_INSERTITEM, 0, DllStructGetPtr($stLvItem))

If $nIndex > -1 Then
; Insert now the rest of the column text
For $i = 2 To $arText[0]
DllStructSetData($stText, 1, $arText[$i])
DllStructSetData($stLvItem, 3, $i - 1) ; Store the subitem index

GUICtrlSendMsg($nCtrlID, $LVM_SETITEMTEXT, $nIndex, DllStructGetPtr($stLvItem))
Next
EndIf

$stText = 0
$stLvItem = 0

; Change the column width to fit the item text
For $i = 0 To 2
GUICtrlSendMsg($nCtrlID, $LVM_SETCOLUMNWIDTH, $i, -1)
GUICtrlSendMsg($nCtrlID, $LVM_SETCOLUMNWIDTH, $i, -2)
Next
EndFunc


Function GUICtrlSendMsg

Function Reference

GUICtrlSendMsg

Send a message to a control.

GUICtrlSendMsg ( controlID, msg , wParam, lParam )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
msg | type of message to be send to the control as defined in the Windows control documentation.
wParam | The first param to send to the control.
lParam | The second param to send to the control.

Return Value

Success: | Returns the value returned by the SendMessage Windows API.
Failure: | Returns 0.

Remarks

This function allows the sending of special Windows messages directly to the control using the SendMessage API. It is used to enable special control features not available with the simple GUICtrlRead() and GUICtrlSet...() range of functions.

The parameters (wParam and lParam) can be an integer or a string.

GUICtrlSendMsg should be used for messages that have no special return types. For more advanced messages where you must be able to receive extra data you must use GUICtrlRecvMsg().

Related

GUICtrlRecvMsg, GUICtrlCreate..., GUICtrlSet..., GUIGetMsg, GUICtrlRead

Example

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>

GUICreate("My GUI") ; will create a dialog box that when displayed is centered

$nEdit = GUICtrlCreateEdit ("line 0", 10,10)
GUICtrlCreateButton ("Ok", 20,200,50)
GUISetState ()

For $n=1 To 5
GUICtrlSetData ($nEdit,@CRLF & "line "& $n)
Next

; Run the GUI until the dialog is closed
Do
$msg = GUIGetMsg()
If $msg >0 Then
$n=GUICtrlSendMsg ($nEdit, $EM_LINEINDEX,-1,0)
$nline=GUICtrlSendMsg( $nEdit, $EM_LINEFROMCHAR,$n,0)
GUICtrlSetState ($nEdit,$GUI_FOCUS) ; set focus

MsgBox (0,"Currentline",$nLine)
EndIf
Until $msg = $GUI_EVENT_CLOSE


Function GUICtrlSendToDummy

Function Reference

GUICtrlSendToDummy

Sends a message to a Dummy control.

GUICtrlSendToDummy ( controlID [, state] )

Parameters

controlID | The control identifier (controlID) as returned by GUICtrlCreateDummy
state | [optional] value that can be retrieved later on by GUICtrlRead

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

When this function is called a notification that can be handled through the message loop or with a OnEvent function is generated (as if the control had been "clicked" on).

Related

GUICtrlCreateDummy, GUICtrlSetOnEvent, GUICtrlRead

Example

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)

GUICreate("GUISendToDummy",220,200, 100,200)
GUISetBkColor (0x00E0FFFF) ; will change background color
GUICtrlSetOnEvent($GUI_EVENT_CLOSE, "OnClick") ; to handle click on button

$user = GUICtrlCreateDummy()
GUICtrlSetOnEvent(-1, "Onexit") ; to handle click on button
$button = GUICtrlCreateButton ("event",75,170,70,20)
GUICtrlSetOnEvent(-1, "OnClick") ; to handle click on button
GUISetState()

While 1
Sleep (100)
Wend

Exit

Func OnClick()
GUICtrlSendToDummy($user) ; fired dummy control
EndFunc

Func OnExit()
; special action before exiting
Exit
EndFunc


Function GUICtrlSetBkColor

Function Reference

GUICtrlSetBkColor

Sets the background color of a control.

GUICtrlSetBkColor ( controlID, backgroundcolor )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
backgroundcolor | The RGB color to use.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

Only Button, Label, Checkbox, Group, Radio, Edit, Input, List, Listview, ListviewItem, Treeview, TreeviewItem, Graphic, Progress and Slider controls can currently be colored.

Progress controls cannot be painted if the "Windows XP style" is used.

Button controls are always painted in "Windows Classic style". They cannot have the $BS_ICON style.

Earlier versions of AutoIt (prior to v3.0.102) used the BGR format for defining color - newer versions use RGB by default but this can be changed using the ColorMode option.

The special flag $GUI_BKCOLOR_TRANSPARENT can be used with label control to give them a transparent background. Picture controls have always a transparent color.

The special flag $GUI_BKCOLOR_LV_ALTERNATE can be used with Listview control to give alternate background of the ListviewItems lines.
The odd lines will get the color set by GUICtrlSetBkColor of the Listview control.
The even lines will get the color set by GUICtrlSetBkColor of the ListviewItem control.

Related

ColorMode (Option), GUICtrlCreate..., GUICtrlSetColor, GUICtrlSetBkColor

Example

#include <GUIConstants.au3>

GUICreate("My GUI background color") ; will create a dialog box that when displayed is centered

GUICtrlCreateLabel ("my label", 10,20)
GUICtrlSetBkColor(-1,0x00ff00) ; Green

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlSetColor

Function Reference

GUICtrlSetColor

Sets the text color of a control.

GUICtrlSetColor ( controlID, textcolor)

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
textcolor | The RGB color to use.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

Only Button, Label, Checkbox, Group, Radio, Edit, Input, List, Listview, ListviewItem, Treeview, TreeviewItem, Graphic and Progress controls can currently be colored.

Checkbox or Progress controls cannot be painted if the "Windows XP style" is used.

Button controls are always painted in "Windows Classic style".

Earlier versions of AutoIt (prior to v3.0.102) used the BGR format for defining color - newer versions use RGB by default but this can be changed using the ColorMode option.

Related

ColorMode (Option), GUICtrlCreate..., GUICtrlSetBkColor

Example

#include <GUIConstants.au3>

GUICreate("My GUI color text") ; will create a dialog box that when displayed is centered

GUICtrlCreateLabel ("my Red label", 10,20)
GUICtrlSetColor(-1,0xff0000) ; Red

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlSetCursor

Function Reference

GUICtrlSetCursor

Sets the mouse cursor icon for a particular control.

GUICtrlSetCursor ( controlID, cursorID )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
cursorID | cursor ID as used by Windows SetCursor API (use -1 for the default mouse cursor for the control)

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

Unlike GUISetCursor which changes the mouse cursor for an entire window, this function sets the mouse cursor that is used when the mouse is hovering over the specified control.

If the cursorID is invalid the standard arrow will be displayed.

For a list of valid cursor IDs see MouseGetCursor.
CursorId = 16 will hide the mouse cursor.

Related

GUISetCursor

Example

#include <GUIConstants.au3>

GUICreate("put cursor over label", 300, 100)
GUICtrlCreateLabel("label",125,40)
GUICtrlSetCursor(-1, 4)
GUISetState ()

While GUIGetMsg()<> $GUI_EVENT_CLOSE
WEnd
Exit


Function GUICtrlSetData

Function Reference

GUICtrlSetData

Modifies the data for a control.

GUICtrlSetData ( controlID, data [, default] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
data | For Combo, List, ListView, ListViewItem : itemtext separated with Opt("GUIDataSeparatorChar",...) For Progress : percent value For Slider : value For Group, Label, Button, Checkbox, Radio, Combo, List, Input, Edit, TabItem : text update For Date : date or time depending the style of the control For TreeViewItem: text update For Dummy : value.
default | [optional] for Combo, List : the value that will be the default. for Edit, Input : if defined and not "" the "data" string is inserted not overriding the previous value at the caret point.

Return Value

Success: | Returns 1.
Failure: | Returns 0.
 | Returns -1 in case of invalid data

Remarks

For Combo or List control :
If the "data" corresponds to an already existing entry it is set as the default.
If the "data" starts with GUIDataSeparatorChar or is an empty string "" the previous list is destroyed.

For ListView, ListViewItem controls :
To update a specific column just forget about the others ie "||update" to update 3rd column.
If "update" is empty the column/subitem will be erased. For example "|" will erase the second column/subitem, "" will erase the first.

Related

GUICtrlCreate..., GUICtrlSet..., GUICtrlRead, GUIDataSeparatorChar (Option)

Example

#include <GUIConstants.au3>

GUICreate("My GUI") ; will create a dialog box that when displayed is centered

GUICtrlCreateCombo ("", 10,10)

GUICtrlSetData(-1,"item1|item2|item3", "item3")

GUISetState () ; will display an empty dialog box with a combo control with focus on

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlSetFont

Function Reference

GUICtrlSetFont

Sets the font for a control.

GUICtrlSetFont (controlID, size [, weight [, attribute [, fontname]]] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
size | Fontsize (default is 8.5).
weight | [optional] Font weight (default 400 = normal).
attribute | [optional] To define italic:2 underlined:4 strike:8 char format (add together the values of all the styles required, 2+4 = italic and underlined).
fontname | [optional] The name of the font to use.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

By default, controls use the font set by GUISetFont.

Size can contain a decimal as in 8.5.

For some control as label ones the default can be 8.5 instead of 9 according to Windows Theme Values.

See the Appendix for a complete list of Windows fonts and the Windows versions under which they are supported.

Related

GUICtrlCreate..., GUISetFont

Example

#include <GUIConstants.au3>

GUICreate ("My GUI") ; will create a dialog box that when displayed is centered

$font="Comic Sans MS"
GUICtrlCreateLabel ("underlined label",10,20)
GUICtrlSetFont (-1,9, 400, 4, $font) ; will display underlined characters

GUICtrlCreateLabel ("italic label", 10,40)
GUICtrlSetFont (-1,9, 400, 2, $font) ; will display italic characters

GUISetFont (9, 400, 8, $font) ; will display strike characters
GUICtrlCreateLabel ("strike label",10,60)

GUISetState () ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlSetImage

Function Reference

GUICtrlSetImage

Sets the bitmap or icon image to use for a control.

GUICtrlSetImage ( controlID, filename [, iconname [, icontype]] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
filename | The filename containing the picture to be display on the control.
iconname | [optional] Icon name if the file contain multiple icon. Can be an ordinal name if negative number. Otherwise -1.
icontype | [optional] To select a specific icon size : 0 = small, 1 = normal (default). for a TreeViewItem the icon size : 2 = selected, 4 for non-selected item.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

Use a resource hacker to know the value of the valid icon name in a file.

If used on a Button control the image will be displayed on the button. Images can also be set for Checkbox controls as long as the $BS_PUSHLIKE style is used. In both case the $BS_ICON or $BS_BITMAP styles are needed to select the type of the picture used. The first icon resolution will be used in a multi icon resolution file. I.E. if a 128x128 is the first resolution and the control is 64x64 the image will be truncated.

!!! If use this command on a TreeViewItem the first time, then all other items will use this icon/image automatically by default !!!
If you use GUICtrlSetImage on a TreeView or ListView then all items of it will change to this icon/image.

Passing a positive number will reference the string equivalent icon name.
Passing a negative number causes 1-based "index" behaviour. Some Dll can have icon extracted just with negative numbers.

Related

GUICtrlCreatePic, GUICtrlCreateIcon, GUICtrlCreateButton, GUICtrlCreateCheckbox

Example

#include <GUIConstants.au3>

GUICreate("My GUI") ; will create a dialog box that when displayed is centered

GUICtrlCreateButton ("my picture button", 10,20,40,40, $BS_ICON)
GUICtrlSetImage (-1, "shell32.dll",22)

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlSetLimit

Function Reference

GUICtrlSetLimit

Limits the number of characters/pixels for a control.

GUICtrlSetLimit ( controlID, max [, min] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
max | For List controls it is the extent you can scroll horizontally in pixels. For Input/Edit controls it is the max number of characters that can be entered.
min | [optional] For Slider and UpDown controls you can specify a min value. Default = 0

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

None.

Related

GUICtrlCreateList, GUICtrlCreateInput, GUICtrlCreateEdit

Example

#include <GUIConstants.au3>

GUICreate("My GUI limit input 3 chars") ; will create a dialog box that when displayed is centered

GUICtrlCreateInput("", 10,20)
GUICtrlSetLimit(-1,3) ; to limit the entry to 3 chars

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlSetOnEvent

Function Reference

GUICtrlSetOnEvent

Defines a user-defined function to be called when a control is clicked.

GUICtrlSetOnEvent ( controlID, "function" )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
function | The name of the user function to call.

Return Value

Success: | Returns 1.
Failure: | Returns 0,

Remarks

OnEvent functions are only called when the option GUIOnEventMode is set to 1 - when in this mode GUIGetMsg is NOT used at all.

Within the called user function the control identifier can be retrieved with @GUI_CTRLID.
If needed the windows handle and the control handle can be retrieved with @GUI_WINHANDLE or @GUI_CTRLHANDLE.

If the function is an empty string "" the previous user-defined is disabled.

Related

GUICreate, GUICtrlCreate..., GUIGetMsg, GUIOnEventMode (Option), GUISetOnEvent

Example

#include <GUIConstants.au3>

Opt("GUICoordMode",2)
Opt("GUIResizeMode", 1)
Opt("GUIOnEventMode", 1)

$parent1 = GUICreate("Parent1")
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")

$ok1 = GUICtrlCreateButton ("OK", 10, 30, 50)
GUICtrlSetOnEvent(-1, "OKPressed")

$cancel1 = GUICtrlCreateButton ( "Cancel", 0, -1)
GUICtrlSetOnEvent(-1, "CancelPressed")

GUISetState(@SW_SHOW)

; Just idle around
While 1
Sleep(10)
Wend

; END

Func OKPressed()
MsgBox(0, "OK Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE & " CtrlHandle=" & @GUI_CTRLHANDLE)
EndFunc

Func CancelPressed()
MsgBox(0, "Cancel Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE & " CtrlHandle=" & @GUI_CTRLHANDLE)
EndFunc

Func SpecialEvents()

Select
Case @GUI_CTRLID = $GUI_EVENT_CLOSE
MsgBox(0, "Close Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)
Exit

Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE
MsgBox(0, "Window Minimized", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)

Case @GUI_CTRLID = $GUI_EVENT_RESTORE
MsgBox(0, "Window Restored", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)

EndSelect

EndFunc


Function GUICtrlSetPos

Function Reference

GUICtrlSetPos

Changes the position of a control within the GUI window.

GUICtrlSetPos ( controlID, left, top [, width [, height]] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
left | The left side of the control.
top | The top of the control.
width | [optional] The width of the control.
height | [optional] The height of the control .

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

None.

Related

GUICtrlCreate...

Example

#include <GUIConstants.au3>

GUICreate("My GUI position") ; will create a dialog box that when displayed is centered

$right = 0
$label=GUICtrlCreateLabel ( "my moving label", 10,20)

$button = GUICtrlCreateButton ("Click to close", 50,50)
GUICtrlSetState(-1,$GUI_FOCUS) ; the focus is on this button

GUISetState ()

While 1
$msg = GUIGetMsg()

if $msg = $button Or $msg = $GUI_EVENT_CLOSE then Exit
If $right = 0 then
$right = 1
GUICtrlSetPos ($label, 20,20)
else
$right = 0
GUICtrlSetPos ($label, 10,20)
endif
Sleep(100)
Wend


Function GUICtrlSetResizing

Function Reference

GUICtrlSetResizing

Defines the resizing method used by a control.

GUICtrlSetResizing ( controlID, resizing )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
resizing | See the Docking Values table below for values that can be used (add together multiple values if required).

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

When a GUI window is resized the controls within react - how they react is determined by this function. To be able to resize a GUI window it needs to have been created with the $WS_SIZEBOX and $WS_SYSMENU styles. See GUICreate.

Docking Values Table
Resizing | Value | No displacement of
$GUI_DOCKAUTO | 1 | resize and reposition according to new window size
$GUI_DOCKLEFT | 2 | Left side
$GUI_DOCKRIGHT | 4 | Right side
$GUI_DOCKHCENTER | 8 | Position will not move relative to horizontal center
$GUI_DOCKTOP | 32 | Top side
$GUI_DOCKBOTTOM | 64 | Bottom side
$GUI_DOCKVCENTER | 128 | Position will not move relative to vertical center
$GUI_DOCKWIDTH | 256 | Width will not change
$GUI_DOCKHEIGHT | 512 | Height will not change
$GUI_DOCKSIZE | 768 | Size will not change (256+512)
$GUI_DOCKMENUBAR | 544 | 512+32 so the control will stay on the top of window with no changing Height
$GUI_DOCKSTATEBAR | 576 | 512+64 so the control stay at the bottom of the window with no changing Height
$GUI_DOCKALL | 802 | 2+32+256+512 so the control will not move during resizing
$GUI_DOCKBORDERS | 102 | 2+4+32+64 so the control will grow as the window

The default resizing for a given control is control depend see control doc.
The automatic resizing can be disabled if GUIEventOptions (Option) is set to 1.

Related

GUIEventOptions (Option)

Example

#include <GUIConstants.au3>

Opt("GUICoordMode", 2)
GUICreate ("My InputBox",190,114,-1,-1,$WS_SIZEBOX+$WS_SYSMENU) ; start the definition
GUISetIcon ("Eiffel Tower.ico")

GUISetFont (8,-1,"Arial")

GUICtrlCreateLabel ("Prompt", 8,7) ; add prompt info
GUICtrlSetResizing (-1,$GUI_DOCKLEFT+$GUI_DOCKTOP)

$nEdit = GUICtrlCreateInput ("Default", -1,3,175,20,$ES_PASSWORD) ; add the input area
GUICtrlSetState ($nEdit,$GUI_FOCUS)
GUICtrlSetResizing ($nEdit,$GUI_DOCKBOTTOM+$GUI_DOCKHEIGHT)

$nOk = GUICtrlCreateButton ("OK",-1,3,75,24) ; add the button that will close the GUI
GUICtrlSetResizing ($nOk,$GUI_DOCKBOTTOM+$GUI_DOCKSIZE+$GUI_DOCKHCENTER)

$nCancel = GUICtrlCreateButton ("Annuler", 25,-1) ; add the button that will close the GUI
GUICtrlSetResizing ($nCancel,$GUI_DOCKBOTTOM+$GUI_DOCKSIZE+$GUI_DOCKHCENTER)

GUISetState () ; to display the GUI

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlSetState

Function Reference

GUICtrlSetState

Changes the state of a control.

GUICtrlSetState ( controlID, state )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
state | See the State table below.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

State table
State | Comments
No Change | 0
$GUI_UNCHECKED | Radio, Checkbox or ListViewItem will be unchecked
$GUI_CHECKED | Radio, Checkbox or ListViewItem will be checked
$GUI_INDETERMINATE | Checkbox having the tristate attribute will be greyed
$GUI_AVISTART | Avi control will start playing
$GUI_AVISTOP | Avi control will stop playing
$GUI_AVICLOSE | Avi control will stop playing and release resource
$GUI_DROPACCEPTED | Control will accept drop action : from file or from a drag of another control. See remarks
$GUI_NODROPACCEPTED | Control will not accept drop action
$GUI_SHOW | Control will be visible. On Tabitem control will select the first tab to be displayed
$GUI_HIDE | Control will not be visible
$GUI_ENABLE | Control will be enabled
$GUI_DISABLE | Control will be greyed out
$GUI_FOCUS | Control will be given input/selected focus
$GUI_NOFOCUS | Listview control will loose focus
$GUI_DEFBUTTON | Control will be set as the default button on the window
$GUI_EXPAND | TreeViewItem will expand it's child items.
$GUI_ONTOP | Control will be have the ontop attribute for the window (zOrdering).

State values can be summed up as for example $GUI_DISABLE + $GUI_HIDE sets the control in an disabled and hidden state.

If an AVI control has to be hidden with $GUI_HIDE it should be closed with $GUI_AVICLOSE.

State of a "contextmenu" control cannot be changed.
State of a "listviewitem" control can be changed if the associated "listview" control has been created with an extended style $LVS_EX_CHECKBOXES. $GUI_FOCUS and $GUI_NOFOCUS can be used on specific listviewitem provided listview control style allows to display it : $LVS_SHOWSELALWAYS.
State of a "menu or a ""menuitem" control cannot be hidden.

! Important information for $GUI_EXPAND: this state is only used for TreeViewItems. If you want to use this 'action' then at least 1 Sub-TreeViewItem has to exist/created under this item !
If you want to select another item in a TreeView then you can use $GUI_FOCUS - the parent TreeView gets the window focus and the specified item is marked as selected.
If you want to set a treeview item as a default item which means painting it bold you can use $GUI_DEFBUTTON - to turn it off just use another value but $GUI_DEFBUTTON, for instance 0.

If $GUI_DROPACCEPTED is set to a visible control a drag&drop can be taken in account. The edit/input control will be set with the filename.
For other controls on reception of $GUI_EVENT_DROPPED, @GUI_DRAGID will return the controlID from where the drag start (-1 if from a file, @GUI_DRAGFILE contain the filename being dropped) and @GUI_DROPID returns the controlID of the dropped control.
Only dragging a ListviewItem will start the drag & drop process. The @GUI_DRAGID will be the ListView controlID.

Related

ColorMode (Option), GUICtrlCreate..., GUICtrlSetData

Example

#include <GUIConstants.au3>

GUICreate("My GUI state") ; will create a dialog box that when displayed is centered

GUICtrlCreateLabel ("my disable label", 10,20)
GUICtrlSetState(-1,$GUI_DISABLE) ; the label is in disable state

GUICtrlCreateButton ("my button", 50,50)
GUICtrlSetState(-1,$GUI_FOCUS) ; the focus is on this button

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlSetStyle

Function Reference

GUICtrlSetStyle

Changes the style of a control.

GUICtrlSetStyle ( controlID, style [, exStyle] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
style | Defines the style of the control. See GUI Control Styles Appendix.
exStyle | [optional] Defines the extended Style of the control. See Extended Style Table.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

Some styles cannot be changed dynamically, check MSDN documentation. $CBS_UPPERCASE combo style is one example.

Related

GUICtrlCreate...

Example

#include <GUIConstants.au3>

GUICreate("My GUI style") ; will create a dialog box that when displayed is centered

GUICtrlCreateLabel ( "my label which will split on several lines", 10,20, 100, 100)
GUICtrlSetStyle (-1, $SS_RIGHT )

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlSetTip

Function Reference

GUICtrlSetTip

Sets the tip text associated with a control.

GUICtrlSetTip ( controlID, tiptext [, "title" [, icon [, options]]]]] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
tiptext | Tip text that will be displayed when the mouse is hovered over the control.
title | [optional] The title for the tooltip Requires IE5+
icon | [optional] Pre-defined icon to show next to the title: Requires IE5+. Requires a title. 0 = No icon, 1 = Info icon, 2 = Warning icon, 3 = Error Icon
options | [optional] Sets different options for how the tooltip will be displayed (Can be added together): 1 = Display as Balloon Tip Requires IE5+ 2 = Center the tip horizontally along the control.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

This tip text is displayed in a tooltip rectangular area.
To skip an optional parameter, leaving it's default value intact, use the Default keyword.
You may use @CR or @LF to create multi-line tooltips.
The title, icon and Balloon Tip option all require Internet Explorer 5.0 or later in order to function.
To display an icon, you must specify a non-empty title. The icon appears on the same row as the title and thus requires a title to be present.

Related

GUICtrlSet..., Default

Example

#include <GUIConstants.au3>

GUICreate("My GUI control tip") ; will create a dialog box that when displayed is centered

GUICtrlCreateLabel ("my label", 10,20)
GUICtrlSetTip(-1,"tip of my label")

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUIDelete

Function Reference

GUIDelete

Deletes a GUI window and all controls that it contains.

GUIDelete ( [winhandle] )

Parameters

winhandle [optional] Windows handle as returned by GUICreate (default is the previous used).

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

None.

Related

GUICreate

Example

#include <GUIConstants.au3>

GUICreate("My GUI") ; will create a dialog box that when displayed is centered

GUISetState () ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

GUIDelete(); ; will return 1


Function GUIGetCursorInfo

Function Reference

GUIGetCursorInfo

Gets the mouse cursor position relative to GUI window.

GUIGetCursorInfo ( [winhandle] )

Parameters

winhandle [optional] The handle of the window to use. If omitted the "current" window will be used.

Return Value

Success: | returns a five-element array that containing the mouse cursor information:
 | $array[0] = X coord (horizontal)
 | $array[1] = Y coord (vertical)
 | $array[2] = Primary down (1 if pressed, 0 if not pressed)
 | $array[3] = Secondary down (1 if pressed, 0 if not pressed)
 | $array[4] = ID of the control that the mouse cursor is hovering over (or 0 if none)
Failure: | 0 and set @error to 1

Remarks

The coordinates given are relative to the GUI window (known as client coords).

If the "winhandle" parameter is used then the specified window becomes the new "current" window.

The mouse cursor position is successful only on an window created by a GUICreate. When no winhandle it will be successful if the GUI Windows is active.

ListViewItem or TreeViewItem controlID will never be returned, only the parent Listview or TreeView control ID is.

Related

GUICreate, GUIGetMsg

Example

#include <GUIConstants.au3>
$IDC = 0
HotkeySet("{Esc}", "GetPos")

GUICreate("Press Esc to Get Pos", 400, 400)
$x=GUICtrlCreateLabel ("0", 10, 10,50)
$y=GUICtrlCreateLabel ("0", 10, 30,50)
GUISetState()

; Run the GUI until the dialog is closed
Do
$msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE
Exit

Func GetPos()
$a=GUIGetCursorInfo()
GUIctrlSetData($x,$a[0])
GUIctrlSetData($y,$a[1])
EndFunc


Function GUIGetMsg

Function Reference

GUIGetMsg

Polls the GUI to see if any events have occurred.

GUIGetMsg ( [advanced] )

Parameters

advanced [optional] return extended information in an array.
0 = (default) Returns a single event.
1 = returns an array containing the event and extended information.

Return Value

Returns an event, or an array depending on the "advanced" parameter.
The "event" returned is the control ID of the control sending the message, or it is a special event (like the window is closing, minimizing). Or if there is no message, the event is 0.

Event ID | the ID of the control sending the message
0 | No event
$GUI_EVENT_CLOSE | dialog box being closed (either by defined button or system menu).
$GUI_EVENT_MINIMIZE | dialog box minimized with Windows title bar button.
$GUI_EVENT_RESTORE | dialog box restored by click on task bar icon.
$GUI_EVENT_MAXIMIZE | dialog box maximized with Windows title bar button.
$GUI_EVENT_MOUSEMOVE | the mouse cursor has moved.
$GUI_EVENT_PRIMARYDOWN | the primary mouse button was pressed.
$GUI_EVENT_PRIMARYUP | the primary mouse button was released.
$GUI_EVENT_SECONDARYDOWN | the secondary mouse button was pressed.
$GUI_EVENT_SECONDARYUP | the secondary mouse button was released.
$GUI_EVENT_RESIZED | dialog box has been resized.
$GUI_EVENT_DROPPED | End of a Drag&Drop action @GUI_DRAGID, @GUI_DRAGFILE and @GUI_DROPID will be used to retrieve the ID's/file corresponding to the involve control.

When using the "advanced" parameter the information is returned in an array with extended information:
$array[0] = 0 or Event ID or Control ID
$array[1] = The window handle the event is from
$array[2] = The control handle the event is from (if applicable)
$array[3] = The current X position of the mouse cursor (relative to the GUI window)
$array[4] = The current Y position of the mouse cursor (relative to the GUI window)

If the GUIOnEventMode option is set to 1 then the return from GUIGetMsg is always 0 and the @error is set to 1.
If the option GUIEventOptions is set to 1 the minimize, restore and maximize button will not do any action on the window just a simple notification.

Remarks

This function automatically idles the CPU when required so that it can be safely used in tight loops without hogging all the CPU.

Information about the mouse position and the hovering control can be retrieved with GUIGetCursorInfo. No event is fired when the mouse is over a control so GUIGetCursorInfo must be called to retrieve the ControlID.

Related

GUICreate, GUICtrlCreate..., GUICtrlRead, GUIOnEventMode (Option), GUIEventOptions (Option), GUIGetCursorInfo

Example

;-------------------------------------------------------------------------------------
; Example - Press the button to see the value of the radio boxes
; The script also detects state changes (closed/minimized/timeouts, etc).

#include <GUIConstants.au3>

Opt("GUICoordMode", 1)
GUICreate("Radio Box Demo", 400,280)

; Create the controls
$button_1 = GUICtrlCreateButton ("B&utton 1", 30, 20, 120, 40)
$group_1 = GUICtrlCreateGroup ("Group 1", 30, 90, 165, 160)
GUIStartGroup()
$radio_1 = GUICtrlCreateRadio ("Radio &0", 50, 120, 70, 20)
$radio_2 = GUICtrlCreateRadio ("Radio &1", 50, 150, 60, 20)
$radio_3 = GUICtrlCreateRadio ("Radio &2", 50, 180, 60, 20)

; Init our vars that we will use to keep track of GUI events
$radioval1 = 0 ; We will assume 0 = first radio button selected, 2 = last button
$radioval2 = 2

; Show the GUI
GUISetState ()

; In this message loop we use variables to keep track of changes to the radios, another
; way would be to use GUICtrlRead() at the end to read in the state of each control
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
MsgBox(0, "", "Dialog was closed")
Exit
Case $msg = $GUI_EVENT_MINIMIZE
MsgBox(0,"", "Dialog minimized",2)
Case $msg = $GUI_EVENT_MAXIMIZE
MsgBox(0,"", "Dialog restored",2)

Case $msg = $button_1
MsgBox(0, "Default button clicked", "Radio " & $radioval1 )

Case $msg >= $radio_1 AND $msg <= $radio_3
$radioval1 = $msg - $radio_1

EndSelect
WEnd


Function GUIGetStyle

Function Reference

GUIGetStyle

Retrieves the styles of a GUI window.

GUIGetStyle ( [ winhandle] )

Parameters

winhandle [optional] Windows handle as returned by GUICreate (default is the previously used window).

Return Value

Success: | returns a two-element array that containing the styles information:
 | $array[0] = Style
 | $array[1] = ExStyle
Failure: | Returns 0.

Remarks

Be carefull Style changes after GUISetState().

Related

GUICreate, GUISetStyle

Example

#include <GuiConstants.au3>
$NewStyle = False
$hWnd = GUICreate("Gui Style", 260, 100)
$Style = GUICtrlCreateButton("Set Style", 45, 50, 150, 20)

$GuiStyles = GuiGetStyle ($hWnd) ; be careful the style change after opening

GUISetState()

While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
Exit
Case $Style
If Not $NewStyle Then
GuiSetStyle ($WS_POPUPWINDOW + $WS_THICKFRAME, $WS_EX_CLIENTEDGE + $WS_EX_TOOLWINDOW)
GUICtrlSetData($Style, 'Undo Style')
$NewStyle = True
Else
GuiSetStyle ($GuiStyles[0], $GuiStyles[1])
GUICtrlSetData($Style, 'Set Style')
$NewStyle = False
EndIf
Case Else
EndSwitch
WEnd


Function GUISetBkColor

Function Reference

GUISetBkColor

Sets the background color of the GUI window.

GUISetBkColor ( background [, winhandle] )

Parameters

background | Background color of the dialog box.
winhandle | [optional] Windows handle as returned by GUICreate (default is the previously used window).

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

Earlier versions of AutoIt (prior to v3.0.102) used the BGR format for defining color - newer versions use RGB by default but this can be changed using the ColorMode option.

Related

ColorMode (Option), GUICreate

Example

#include <GUIConstants.au3>

GUICreate ("My GUI") ; will create a dialog box that when displayed is centered

GUISetBkColor (0xE0FFFF) ; will change background color

GUISetState () ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUISetCoord

Function Reference

GUISetCoord

Sets absolute coordinates for the next control.

GUISetCoord ( left, top [, width [, height [, winhandle]]] )

Parameters

left | The left side of the control.
top | The top of the control.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
winhandle | [optional] Windows handle as returned by GUICreate (default is the previously used).

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

To be used specifically in Opt ("GUICoordMode", 2). It allows you to set the current position to a precise point and from that position to create controls by row (x_offset,-1) or by columns (-1, y_offset).

Related

GUICtrlCreate...

Example

#include <GUIConstants.au3>

Opt ("GUICoordMode", 2) ; relative to cell mode

GUICreate ("My GUI Set Coord", 200, 100)
GUICtrlCreateCheckbox ("Check #1", 20, 10, 75)
GUICtrlCreateCheckbox ("Notify #2", 10, -1) ; next cell in the line

GUISetCoord(20,60)

GUICtrlCreateButton ("OK #3", -1,-1)
GUICtrlCreateButton ("Cancel #4", 10, -1)
GUICtrlSetState( -1, $GUI_FOCUS)

GUISetState () ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUISetCursor

Function Reference

GUISetCursor

Sets the mouse cursor icon for a GUI window.

GUISetCursor ( [cursorID [, override [, winhandle]]] )

Parameters

cursorID | [optional] Cursor Id (See Remarks).
override | [optional] Force the requested mouse cursor even when over controls (see below). 0 = (default) Don't override a control's default mouse cursor. 1= override control's default mouse cursor.
winhandle | [optional] Windows handle as returned by GUICreate (default is the previously used Window).

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

If the cursorID is invalid the standard arrow will be displayed.

Usually when you move the mouse cursor over an edit control or other control the mouse cursor changes shape. The "override" option allows you to force the requested mouse cursor to be shown at all times. Note: If you have changed a controls mouse cursor with GUICtrlSetCursor then this control mouse cursor will always be shown.

For a list of valid cursor IDs see MouseGetCursor.
CursorId = 16 will hide the mouse cursor.

Related

GUICtrlSetCursor

Example

#include <GUIConstants.au3>

$IDC = -1
$newIDC = 0

HotkeySet("{Esc}", "Increment")

GUICreate("Press Esc to Increment", 400, 400,0,0,0x04CF0000, 0x00000110)

GUISetState ()

While GUIGetMsg()<> $GUI_EVENT_CLOSE
If $newIDC <> $IDC Then
$IDC = $newIDC
GUISetCursor($IDC)
EndIf
ToolTip("GUI Cursor #" & $IDC)
WEnd
Exit

Func Increment()
$newIDC = $IDC + 1
If $newIDC > 15 Then $newIDC = 0
EndFunc


Function GUISetFont

Function Reference

GUISetFont

Sets the default font for a GUI window.

GUISetFont (size [, weight [, attribute [, fontname [, winhandle]]]] )

Parameters

size | Fontsize (default is 8.5).
weight | [optional] Font weight (default 400 = normal).
attribute | [optional] To define italic:2 underlined:4 strike:8 char format (add together the values of all the styles required, 2+4 = italic and underlined).
fontname | [optional] Font to use. (OS default GUI font is used if the font is "" or is not found).
winhandle | [optional] Windows handle as returned by GUICreate (default is the previously used window).

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

See the Appendix for a complete list of Windows fonts and Windows versions under which they are supported.

Size can contain a decimal as in 8.5.

For some control as label ones the default can be 8.5 instead of 9 according to Windows Theme Values.

Related

GUICtrlSetFont

Example

#include <GUIConstants.au3>

GUICreate ("My GUI default font") ; will create a dialog box that when displayed is centered

$font="Comic Sans MS"
GUISetFont (9, 400, 4, $font) ; will display underlined characters
GUICtrlCreateLabel ("underlined label",10,20)

GUISetFont (9, 400, 2, $font) ; will display underlined characters
GUICtrlCreateLabel ("italic label", 10,40)

GUISetFont (9, 400, 8, $font) ; will display underlined characters
GUICtrlCreateLabel ("strike label",10,60)

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUISetHelp

Function Reference

GUISetHelp

Sets an executable file that will be run when F1 is pressed.

GUISetHelp ( helpfile [, winhandle] )

Parameters

helpfile | file that will be run if F1 is pressed when the GUI is active.
winhandle | [optional] Windows handle as returned by GUICreate (default is the previously used window).

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

None.

Related

GUICreate

Example

#include <GUIConstants.au3>

GUICreate("My GUI") ; will create a dialog box that when displayed is centered

GUISetHelp("notepad") ; will run notepad if F1 is typed

GUISetState () ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUISetIcon

Function Reference

GUISetIcon

Sets the icon used in a GUI window.

GUISetIcon ( iconfile [, iconID [, winhandle]] )

Parameters

iconfile | used to display the icon in the title area.
iconID | [optional] The ID of the icon in the iconfile. (Default is -1).
winhandle | [optional] Windows handle as returned by GUICreate (default is the previously used window).

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

Passing a positive number will reference the string equivalent icon name.
Passing a negative number causes 1-based "index" behaviour. Some Dll can have icon extracted

just with negative numbers.

Related

GUICreate

Example

#include <GUIConstants.au3>

GUICreate ("My GUI new icon") ; will create a dialog box that when displayed is centered

GUISetIcon ("autosave.ico") ; will change icon

GUISetState ( ); will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUISetOnEvent

Function Reference

GUISetOnEvent

Defines a user function to be called when a system button is clicked.

GUISetOnEvent ( specialID, "function" [, winhandle] )

Parameters

specialID | See the Special ID table below.
function | The name of the user function to call.
winhandle | [optional] Windows handle as returned by GUICreate (default is the previously used window).

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

OnEvent functions are only called when the option GUIOnEventMode is set to 1 - when in this mode GUIGetMsg is NOT used at all.

If the option GUIEventOptions is set to 1 the minimize, restore and maximize button will not do any action on the window just a simple notification.

If the function is an empty string "" the previous user-defined is disabled.

Special ID table
Special Id | Comments
$GUI_EVENT_CLOSE | dialog box being closed (either by defined button or system menu).
$GUI_EVENT_MINIMIZE | dialog box minimized with Windows title bar button.
$GUI_EVENT_RESTORE | dialog box restored by click on task bar icon.
$GUI_EVENT_MAXIMIZE | dialog box maximized with Windows title bar button.
$GUI_EVENT_MOUSEMOVE | the mouse cursor has moved.
$GUI_EVENT_PRIMARYDOWN | the primary mouse button was pressed.
$GUI_EVENT_PRIMARYUP | the primary mouse button was released.
$GUI_EVENT_SECONDARYDOWN | the secondary mouse button was pressed.
$GUI_EVENT_SECONDARYUP | the secondary mouse button was released.
$GUI_EVENT_RESIZED | dialog box has been resized.
$GUI_EVENT_DROPPED | End of a Drag&Drop action @GUI_DRAGID, @GUI_DRAGFILE and @GUI_DROPID will be used to retrieve the ID's/file corresponding to the involve control.

Related

GUIOnEventMode (Option), GUIEventOptions (Option), GUICtrlSetOnEvent

Example

#include <GUIConstants.au3>

Opt("GUICoordMode",2)
Opt("GUIResizeMode", 1)
Opt("GUIOnEventMode", 1)

$parent1 = GUICreate("Parent1")
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")

$ok1 = GUICtrlCreateButton ("OK", 10, 30, 50)
GUICtrlSetOnEvent(-1, "OKPressed")

$cancel1 = GUICtrlCreateButton ( "Cancel", 0, -1)
GUICtrlSetOnEvent(-1, "CancelPressed")

GUISetState(@SW_SHOW)

; Just idle around
While 1
Sleep(10)
Wend

; END

Func OKPressed()
MsgBox(0, "OK Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE & " CtrlHandle=" & @GUI_CTRLHANDLE)
EndFunc

Func CancelPressed()
MsgBox(0, "Cancel Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE & " CtrlHandle=" & @GUI_CTRLHANDLE)
EndFunc

Func SpecialEvents()

Select
Case @GUI_CTRLID = $GUI_EVENT_CLOSE
MsgBox(0, "Close Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)
Exit

Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE
MsgBox(0, "Window Minimized", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)

Case @GUI_CTRLID = $GUI_EVENT_RESTORE
MsgBox(0, "Window Restored", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)

EndSelect

EndFunc


Function GUISetState

Function Reference

GUISetState

Changes the state of a GUI window.

GUISetState ( [flag [, winhandle]] )

Parameters

flag | [optional] @SW_SHOW = Shows a previously hidden window (default) @SW_HIDE = Hide window @SW_MINIMIZE = Minimize window @SW_MAXIMIZE = Maximize window @SW_RESTORE = Undoes a window minimization @SW_DISABLE = Disables the window @SW_ENABLE = Enables the window @SW_LOCK = Lock the window to avoid repainting. @SW_UNLOCK = Unlock windows to allow painting.
winhandle | [optional] Windows handle as returned by GUICreate (default is the previously used window).

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

When windows are created they are initially hidden so you must use this function to display them (@SW_SHOW).

Only one window can be locked with @SW_LOCK and it is always the last one referenced.

Related

GUICreate

Example

#include <GUIConstants.au3>

GUICreate ("My GUI") ; start the definition

GUISetState () ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUISetStyle

Function Reference

GUISetStyle

Changes the styles of a GUI window.

GUISetStyle ( Style [,ExStyle [, winhandle]] )

Parameters

style | defines the style of the window. See GUI Control Styles Appendix. Use -1 to leave it unchanged.
exStyle | [optional] defines the extended style of the window. See the Extended Style Table below. -1 is the default. Use -1 to leave it unchanged.
winhandle | [optional] Windows handle as returned by GUICreate (default is the previously used window).

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

No checking is done on style value, neither non interaction with already defined control. It is the designer responsability to take care of this compatibility.

Related

GUICreate, GUIGetStyle

Example

#include <GuiConstants.au3>
$NewStyle = False
$hWnd = GUICreate("Gui Style", 260, 100)
$Style = GUICtrlCreateButton("Set Style", 45, 50, 150, 20)
GUISetState()

While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
Exit
Case $Style
If Not $NewStyle Then
GuiSetStyle ($WS_POPUPWINDOW + $WS_THICKFRAME, $WS_EX_CLIENTEDGE + $WS_EX_TOOLWINDOW)
GUICtrlSetData($Style, 'Undo Style')
$NewStyle = True
Else
GuiSetStyle ($WS_MINIMIZEBOX + $WS_CAPTION + $WS_POPUP + $WS_SYSMENU, 0)
GUICtrlSetData($Style, 'Set Style')
$NewStyle = False
EndIf
Case Else
EndSwitch
WEnd


Function GUIStartGroup

Function Reference

GUIStartGroup

Defines that any subsequent controls that are created will be "grouped" together.

GUIStartGroup ( [winhandle] )

Parameters

winhandle [optional] Windows handle as returned by GUICreate (default is the previously used window).

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

This function is generally used when working with radio button controls. When you click a radio button all other radio buttons in the same grouping are reset. The GUIStartGroup function allows you to easily define these groups.

Related

GUICtrlCreateGroup

Example

#include <GUIconstants.au3>

Opt("GUICoordMode", 1)

GUICreate("Radio Box Grouping Demo", 400,280)

; Create the controls
$button_1 = GUICtrlCreateButton ("B&utton 1", 30, 20, 120, 40)
$group_1 = GUICtrlCreateGroup ("Group 1", 30, 90, 165, 160)
GUIStartGroup()
$radio_1 = GUICtrlCreateRadio ("Radio &0", 50, 120, 70, 20)
$radio_2 = GUICtrlCreateRadio ("Radio &1", 50, 150, 60, 20)
$radio_3 = GUICtrlCreateRadio ("Radio &2", 50, 180, 60, 20)
GUIStartGroup()
$radio_4 = GUICtrlCreateRadio ("Radio &A", 120, 120, 70, 20)
$radio_5 = GUICtrlCreateRadio ("Radio &B", 120, 150, 60, 20)
$radio_6 = GUICtrlCreateRadio ("Radio &C", 120, 180, 60, 20)
GUIStartGroup()
$input_1 = GUICtrlCreateInput ("Input 1", 200, 20, 160, 30)
$input_2 = GUICtrlCreateInput ("Input 2", 200, 70, 160, 30)

; Set the defaults (radio buttons clicked, default button, etc)
GUICtrlSetState($radio_1, $GUI_CHECKED)
GUICtrlSetState($radio_6, $GUI_CHECKED)
GUICtrlSetState($button_1, $GUI_FOCUS + $GUI_DEFBUTTON)

; Init our vars that we will use to keep track of radio events
$radioval1 = 0 ; We will assume 0 = first radio button selected, 2 = last button
$radioval2 = 2

GUISetState ()

; In this message loop we use variables to keep track of changes to the radios, another
; way would be to use GUICtrlRead() at the end to read in the state of each control. Both
; methods are equally valid
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit

Case $msg = $button_1
MsgBox(0, "Button", "Radio " & $radioval1 & @LF & "Radio " & Chr($radioval2 + Asc("A")) & @LF & GUICtrlRead($input_1) & @LF & GUICtrlRead($input_2))

Case $msg = $radio_1 OR $msg = $radio_2 OR $msg = $radio_3
$radioval1 = $msg - $radio_1

Case $msg = $radio_4 OR $msg = $radio_5 OR $msg = $radio_6
$radioval2 = $msg - $radio_4

EndSelect
WEnd


Function GUISwitch

Function Reference

GUISwitch

Switches the current window used for GUI functions.

GUISwitch ( winhandle [, tabitemID] )

Parameters

winhandle | The handle of the window to switch to.
tabitemID | controlID of the tabitem control to be selected.

Return Value

Success: | Returns the handle of the previously current.
Failure: | Returns a NULL handle.

Remarks

Many of the GUI specific functions work on the "current" window - this is usually the last window created with GUICreate. This function allows you to make another window "current". That's does not mean that the referenced window will become active. You have to use WinActivate.

Using the tabitemID allow to create new control in the specified tabitem control. Don't forget to close tabitem definition GuiCtrlCreateTabItem("")

Related

GUICreate, GUIDelete

Example

#include <GUIConstants.au3>

$parent1= GUICreate("Parent1")
GUICtrlCreateTab(10,10)
$tabitem = GUICtrlCreateTabItem("tab1")
GUICtrlCreateTabItem("tab2")
GUICtrlCreateTabItem("")

$parent2= GUICreate("Parent2", -1, -1, 100, 100)

GUISwitch($parent2)
GUISetState()
Do
$msg=GUIGetMsg()
until $msg = $GUI_EVENT_CLOSE
GuiSwitch($parent1,$tabitem)
GUICtrlCreateButton("OK",50,50,50)
GUICtrlCreateTabItem("")

GUISetState(@SW_SHOW,$parent1)
Do
$msg=GUIGetMsg()
until $msg = $GUI_EVENT_CLOSE


Function HWnd

Function Reference

HWnd

Converts an expression into an HWND handle.

HWnd ( expression )

Parameters

expression An expression to convert into an HWND handle.

Return Value

Success - If the value can be converted to an HWND, the HWND representation will be returned.
Failure - If the HWND does not denote a valid window, a 0 (NULL) HWND will be returned and @error set to 1.

Remarks

Double numbers can not be converted to an HWND.
No literal string should be converted to an HWND because there is no guarantee that a given window will have the same HWND ever again. This is not strictly forbidden, but it is a programming mistake and should be avoided.

Related

Int, String, Number

Example

Run("notepad.exe")
WinWait("Untitled - Notepad")
Local $hWnd = WinGetHandle("Untitled - Notepad")
Local $sHWND = String($hWnd) ; Convert to a string
WinSetState(HWnd($sHWND), "", @SW_MINIMIZE)
Sleep(5000) ; Notepad should be minimized
WinClose(HWnd($sHWND))


Function Int

Function Reference

Int

Returns the integer (whole number) representation of an expression.

Int ( expression )

Parameters

expression An expression to convert into an integer.

Return Value

Success: | Returns a integer.
Failure: | Returns 0 sets @error to 1 if not an integer, float or string.

Remarks

Fractional portions are truncated, so Int(1.999999) returns 1
Int(0/0) returns -9.22337203685478e+018, if you were wondering.

Related

Number, String, Round, HWnd

Example

$var = Int(10.793) ;$var is the integer 10


Function IsArray

Function Reference

IsArray

Checks if a variable is an array type.

IsArray ( variable )

Parameters

variable The variable/expression to check.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if parameter is not an array variable.

Remarks

Can be useful to validate array/non-array parameters to user-defined functions.

Related

IsFloat, IsInt, IsString, IsNumber, IsBool, IsHWnd

Example

$pos = WinGetPos("Untitled -")
If IsArray($pos) Then
MsgBox(0, "Window height", $pos[3])
EndIf


Function IsBinary

Function Reference

IsBinary

Checks if a variable or expression is a binary type.

IsBinary ( expression )

Parameters

variable The variable or expression to check.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if expression is not binary type.

Remarks

None.

Related

IsArray, IsFloat, IsInt, IsString, IsNumber, IsBool, IsHWnd

Example

$bin = Binary("0x00204060")
$str = "0x00204060"

msgbox(0, "IsBinary $bin", IsBinary($bin))
msgbox(0, "IsBinary $str", IsBinary($str))


Function IsBool

Function Reference

IsBool

Checks if a variable's base type is boolean.

IsBool ( variable )

Parameters

variable The variable/expression to check.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if expression is not boolean type.

Remarks

Related

IsArray, IsFloat, IsInt, IsNumber, IsString, IsHWnd

Example

$b = true
If IsBool($b) Then Msgbox(0,"Success", "$b is a boolean variable")


Function IsFloat

Function Reference

IsFloat

Checks if a variable or expression is a float-type.

IsFloat ( variable )

Parameters

variable The variable or expression to check.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if expression is not float type.

Remarks

See examples.

Related

IsArray, IsInt, IsString, IsNumber, IsBool, IsHWnd, StringIsFloat

Example

IsFloat(3.14159) ;returns 1
IsFloat(3.000) ;returns 0 since value is integer 3
IsFloat(1/2 - 5) ;returns 1
IsFloat(1.5e3) ;returns 0 since 1.5e3 = 1500
IsFloat("12.345") ;returns 0 since is a string


Function IsHWnd

Function Reference

IsHWnd

Checks if a variable's base type is HWND.

IsHWnd ( variable )

Parameters

variable The variable/expression to check.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if expression is not HWND type.

Remarks

Related

IsArray, IsFloat, IsInt, IsString, IsNumber, IsBool

Example

Run("notepad.exe")
Local $hWnd = WinGetHandle("Untitled - Notepad")
If IsHWnd($hWnd) Then
MsgBox(4096, "", "It's a valid HWND")
Else
MsgBox(4096, "", "It's not an HWND")
EndIf


Function IsInt

Function Reference

IsInt

Checks if a variable or expression is an integer type.

IsInt ( variable )

Parameters

variable The variable/expression to check.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if expression is not integer.

Remarks

IsInt(7.5 - 2.5) returns 1 (meaning true).

Related

IsArray, IsFloat, IsString, IsNumber, IsBool, IsHWnd, StringIsInt

Example

IsInt(-12345) ;returns 1
IsInt(3.0000) ;returns 1
IsInt("5432") ;returns 0 since is a string
IsInt(7.5 - 4.5) ;returns 1 since evaluates to integer 3


Function IsKeyword

Function Reference

IsKeyword

Checks if a variable is a keyword (for example, Default).

IsKeyword ( variable )

Parameters

variable The variable to check.

Return Value

Success: | Returns 1 if variable is a keyword.
Failure: | Returns 0 if variable is not a keyword.

Remarks

Related

Default

Example

$a = default
If IsKeyword($a) Then MsgBox(0,"Ok", "Yes it is")


Function IsNumber

Function Reference

IsNumber

Checks if a variable's base type is numeric.

IsNumber ( variable )

Parameters

variable The variable/expression to check.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if expression is not numeric type.

Remarks

Variants can be of two base types: Strings and Numbers. Additionally, a number can be whole (integer) or fractional/floating-point.

Related

IsArray, IsFloat, IsInt, IsString, IsBool, IsHWnd

Example

IsNumber(42)


Function IsObj

Function Reference

IsObj

Checks if a variable or expression is an object type.

IsObj ( variable )

Parameters

variable The variable/expression to check.

Return Value

Success: | Returns 1 if expression is an object variable.
Failure: | Returns 0 if expression is not an object variable.

Remarks

Related

ObjGet, ObjCreate

Example

$oShell = ObjCreate("shell.application")
if not IsObj($oShell) then
Msgbox(0,"Error","$oShell is not an Object.")
else
Msgbox(0,"Error","Successfully created Object $oShell.")
endif


Function IsString

Function Reference

IsString

Checks if a variable is a string type.

IsString ( variable )

Parameters

variable The variable/expression to check.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if expression is not string type.

Remarks

None.

Related

IsArray, IsFloat, IsInt, IsNumber, IsBool, IsHWnd, IsBinary

Example

$x = IsString("foo")


Function MouseClick

Function Reference

MouseClick

Perform a mouse click operation.

MouseClick ( "button" [, x, y [, clicks [, speed ]]] )

Parameters

button | The button to click: "left", "right", "middle", "main", "menu", "primary", "secondary".
x, y | [optional] The x/y coordinates to move the mouse to. If no x and y coords are given, the current position is used (default).
clicks | [optional] The number of times to click the mouse. Default is 1.
speed | [optional] the speed to move the mouse in the range 1 (fastest) to 100 (slowest). A speed of 0 will move the mouse instantly. Default speed is 10.

Return Value

Success: | Returns 1.
Failure: | Returns 0, the button is not in the list.

Remarks

If the button is an empty string, the left button will be clicked.

If the user has swapped the left and right mouse buttons in the control panel, then the behaviour of the buttons is different. "Left" and "right" always click those buttons, whether the buttons are swapped or not. The "primary" or "main" button will be the main click, whether or not the buttons are swapped. The "secondary" or "menu" buttons will usually bring up the context menu, whether the buttons are swapped or not.

Button | Normal | Swapped
"" | Left | Left
"left" | Left | Left
"middle" | Middle | Middle
"right" | Right | Right
"primary" | Left | Right
"main" | Left | Right
"secondary" | Right | Left
"menu" | Right | Left

Related

MouseClickDrag, MouseGetPos, MouseMove, MouseCoordMode (Option), MouseClickDelay (Option)

Example

; Double click at the current mouse pos
MouseClick("left")
MouseClick("left")

; Double click at 0,500
MouseClick("left", 0, 500, 2)

; SAFER VERSION of Double click at 0,500

Dim $primary
Dim $secondary
;Determine if user has swapped right and left mouse buttons
$k = RegRead("HKEY_CURRENT_USER\Control Panel\Mouse", "SwapMouseButtons")

; It's okay to NOT check the success of the RegRead operation
If $k = 1 Then
$primary = "right"
$secondary = "left"
Else ;normal (also case if could not read registry key)
$primary = "left"
$secondary = "right"
EndIf
MouseClick($primary, 0, 500, 2)
Exit


Function MouseClickDrag

Function Reference

MouseClickDrag

Perform a mouse click and drag operation.

MouseClickDrag ( "button", x1, y1, x2, y2 [, speed] )

Parameters

button | The button to click: "left", "right", "middle", "main", "menu", "primary", "secondary".
x1, y1 | The x/y coords to start the drag operation from.
x2, y2 | The x/y coords to end the drag operation at.
speed | [optional] the speed to move the mouse in the range 1 (fastest) to 100 (slowest). A speed of 0 will move the mouse instantly. Default speed is 10.

Return Value

Success: | Returns 1.
Failure: | Returns 0, the button is not in the list.

Remarks

If the button is an empty string, the left button will be clicked.

If the user has swapped the left and right mouse buttons in the control panel, then the behaviour of the buttons is different. "Left" and "right" always click those buttons, whether the buttons are swapped or not. The "primary" or "main" button will be the main click, whether or not the buttons are swapped. The "secondary" or "menu" buttons will usually bring up the context menu, whether the buttons are swapped or not. See the table in MouseClick for more explaination

Related

MouseClick, MouseGetPos, MouseMove, MouseCoordMode (Option), MouseClickDragDelay (Option)

Example

; Left click drag from 0,200 to 600, 700
MouseClickDrag("left", 0, 200, 600, 700)


Function MouseGetCursor

Function Reference

MouseGetCursor

Returns the cursor ID Number for the current Mouse Cursor.

MouseGetCursor ( )

Parameters

None.

Return Value

Returns a cursor ID Number:
0 = UNKNOWN (this includes pointing and grabbing hand icons)
1 = APPSTARTING
2 = ARROW
3 = CROSS
4 = HELP
5 = IBEAM
6 = ICON
7 = NO
8 = SIZE
9 = SIZEALL
10 = SIZENESW
11 = SIZENS
12 = SIZENWSE
13 = SIZEWE
14 = UPARROW
15 = WAIT

Remarks

None.

Related

MouseGetPos

Example

sleep(2000) ;allow time to move mouse before reporting ID

;create an array that tells us the meaning of an ID Number
$IDs = StringSplit("AppStarting|Arrow|Cross|Help|IBeam|Icon|No|" & _
"Size|SizeAll|SizeNESW|SizeNS|SizeNWSE|SizeWE|UpArrow|Wait", "|")
$IDs[0] = "Unknown"

$cursor = MouseGetCursor()
MsgBox(4096, "ID = " & $cursor, "Which means " & $IDs[$cursor])


Function MouseGetPos

Function Reference

MouseGetPos

Retrieves the current position of the mouse cursor.

MouseGetPos ( [dimension] )

Parameters

Dimension An optional argument that determines what the return value will be. See Return Value.

Return Value

Dimension | Values
None | Returns a two-element array that containing the mouse coordinates: $array[0] = X coord (horizontal), $array[1] = Y coord (vertical)
0 | Returns the X co-ordinate as an integer.
1 | Returns the Y co-ordinate as an integer.

If dimension is not a number @error will be set to 1.

Remarks

See MouseCoordMode for relative/absolute position settings. If relative positioning, numbers may be negative.

Related

MouseClick, MouseClickDrag, MouseMove, MouseCoordMode (Option)

Example

$pos = MouseGetPos()
MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1])


Function MouseMove

Function Reference

MouseMove

Moves the mouse pointer.

MouseMove ( x, y [, speed] )

Parameters

x | The screen x coordinate to move the mouse to.
y | The screen y coordinate to move the mouse to.
speed | [optional] the speed to move the mouse in the range 1 (fastest) to 100 (slowest). A speed of 0 will move the mouse instantly. Default speed is 10.

Return Value

User mouse movement is hindered during a non-instantaneous MouseMove operation.
If MouseCoordMode is relative positioning, numbers may be negative.

Remarks

None.

Related

MouseClick, MouseClickDrag, MouseGetPos, MouseCoordMode (Option)

Example

MouseMove(10, 100)
MouseMove(700, 700, 0)


Function Number

Function Reference

Number

Returns the numeric representation of an expression.

Number ( expression )

Parameters

expression An expression to convert into a number.

Return Value

Returns a number.

Remarks

A string beginning with letters has a numeric value of zero. A string beginning with digits has non-numeric characters stripped.

Related

Int, String

Example

$w = Number(1+2+10) ;returns 13
$x = Number("3.14") ;returns 3.14
$y = Number("24/7") ;returns 24
$z = Number("tmp3") ;returns 0


Function ObjCreate

Function Reference

ObjCreate

Creates a reference to a COM object from the given classname.

ObjCreate ( "classname" [, "servername" [,"username", ["password"]]] )

Parameters

Classname | The class of the object in the following format: "appname.objectype"
Servername | Optional name of a remote computer from which the object must be obtained.
Username | Optional name of a usercode on the remote computer You have to enter this in the format "computer\usercode" or "domain\usercode".
Password | Optional password for the usercode on the remote computer.

Return Value

Success: | Returns an object.
Failure: | Returns 0 and sets @error to 1.

Remarks

Use ObjCreate() if you want to have a new instance of the referring application.
If you want to connect to an existing process, use ObjGet() instead.

Keep in mind that not all computers have the same set of Objects. So always check for errors after calling ObjCreate().

The following requirements apply if you want to access objects on remote computers:
-The user running the script must have the appropriate permissions.
-The Object on the remote computer must support DCOM (Distributed COM)
-The remote computer must have 'Remote Registry Service' and 'File and Printer sharing' services running.

See the Obj/COM Reference for more information about Objects.

Related

GUICtrlCreateObj, IsObj, ObjEvent, ObjGet, ObjName

Example

; Example 1
;
; Counting the number of open shell windows

$oShell = ObjCreate("shell.application") ; Get the Windows Shell Object
$oShellWindows=$oShell.windows ; Get the collection of open shell Windows

if Isobj($oShellWindows) then

$string="" ; String for displaying purposes

for $Window in $oShellWindows ; Count all existing shell windows
$String = $String & $Window.LocationName & @CRLF
next

Msgbox(0,"Shell Windows","You have the following shell windows:" & @CRLF & @CRLF & $String);

endif
exit

; Example 2
;
; Open the MediaPlayer on a REMOTE computer
$oRemoteMedia = ObjCreate("MediaPlayer.MediaPlayer.1","name-of-remote-computer")

If not @error then
Msgbox(0,"Remote ObjCreate Test","ObjCreate() of a remote Mediaplayer Object successful !")
$oRemoteMedia.Open( @WindowsDir & "\media\Windows XP Startup.wav") ; Play sound if file is present
Else
Msgbox(0,"Remote ObjCreate Test","Failed to open remote Object. Error code: " & hex(@error,8))
Endif


Function ObjEvent

Function Reference

ObjEvent

Handles incoming events from the given Object.

ObjEvent ( $ObjectVar, "functionprefix" [, "interface name"] )
ObjEvent ( "AutoIt.Error" [, "function name"] )

Parameters

$ObjectVar | A variable containing an Object from which you want to receive events
"functionprefix" | The prefix of the functions you define to handle receiving events. The prefix is appended by the Objects method name.
"interface name" | Optional name of an Event interface to use. Note: It must be a supported as outgoing for the Object AND it must be of type DISPATCH.

Return Value

Success: | Returns an object or a function name.
Failure: | Returns "" and sets @error to 1.

Remarks

The first format is used to receive Events from the given Object.
To receive a specific event, create an AutoIt function name using
the given prefix appended with the event name.

The second format is used for COM Error Handling. If any COM error
occurs, the given function is being called.
If the second parameter is omitted, it will return the name of the
current Error handler function, if present.

See the Obj/COM Reference for a detailed explanation.

Related

ObjGet, IsObj, ObjCreate

Example

; ObjEvent example

ProgressOn("Example", "Loading page...")
$oIE=ObjCreate("InternetExplorer.Application.1") ; Create Internet Explorer application
$SinkObject=ObjEvent($oIE,"IEEvent_","DWebBrowserEvents2") ; Assign events to UDFs starting with IEEvent_

; Do some browsing activities
$oIE.Visible=1
$oIE.RegisterAsDropTarget = 1
$oIE.RegisterAsBrowser = 1
$oIE.Navigate( "http://www.AutoItScript.com/" )

sleep(3000) ; Give it time to load the web page

$SinkObject=0 ; Stop IE Events
$oIE.Quit ; Quit IE
$oIE=0
exit

; one of many Internet Explorer Event Functions

Func IEEvent_ProgressChange($Progress,$ProgressMax)
$percent = Int( ($Progress * 100) / $ProgressMax )
If $percent >= 0 And $percent <= 100 Then
ProgressSet ( $percent , $percent & " percent to go." , "loading web page" )
EndIf

EndFunc

Exit

; COM Error Handler example
; -------------------------

$oIE=ObjCreate("InternetExplorer.Application.1") ; Create Internet Explorer application
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Initialize a COM error handler

$oIE.UnknownMethod ; Deliberately call an undefined method

If @error then
Msgbox (0,"AutoItCOM test","Test passed: We got an error number: " & @error)
Else
Msgbox (0,"AutoItCOM test","Test failed!")
Endif

Exit

; This is my custom defined error handler
Func MyErrFunc()

Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _
"err.description is: " & @TAB & $oMyError.description & @CRLF & _
"err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _
"err.number is: " & @TAB & hex($oMyError.number,8) & @CRLF & _
"err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _
"err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _
"err.source is: " & @TAB & $oMyError.source & @CRLF & _
"err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _
"err.helpcontext is: " & @TAB & $oMyError.helpcontext _
)

Local $err = $oMyError.number
If $err = 0 Then $err = -1

SetError($err) ; to check for after this function returns
Endfunc


Function ObjGet

Function Reference

ObjGet

Retrieves a reference to a COM object from an existing process or filename.

ObjGet ( "filename" [, "classname"] )

Parameters

Filename | (See remarks) The full path and name to the file containing the object.
Classname | (Optional) The class of the object in the following format: "appname.objectype"

Return Value

Success: | Returns an object.
Failure: | Returns 0 and sets @error to 1.

Remarks

The filename is optional if you want to use only the class name, but the parameter
can't be omitted. Use an empty string if you only want to use the classname.
Like: $Object = ObjGet("","Excel.Application")

If you want to use a filename, the classname is optional. It's only required when
multiple classes are defined to the same file type and you want to access a
specific class.

Keep in mind that not all computers have the same set of Objects. So always check for errors after calling ObjGet().

See the Obj/COM Reference for more information about Objects.

Related

GUICtrlCreateObj, IsObj, ObjCreate, ObjEvent, ObjName

Example

; Example getting an Object using it's class name
;
; Excel must be activated for this example to be successfull

$oExcel = ObjGet("","Excel.Application") ; Get an existing Excel Object

if @error then
Msgbox (0,"ExcelTest","Error Getting an active Excel Object. Error code: " & hex(@error,8))
exit
endif

$oExcel.Visible = 1 ; Let the guy show himself
$oExcel.workbooks.add ; Add a new workbook
exit

; Example getting an Object using a file name
;
; An Excel file with filename Worksheet.xls must be created in the root directory
; of the C:\ drive in order for this example to work.

$FileName="C:\Worksheet.xls"

if not FileExists($FileName) then
Msgbox (0,"Excel File Test","Can't run this test, because you didn't create the Excel file "& $FileName)
Exit
endif

$oExcelDoc = ObjGet($FileName) ; Get an Excel Object from an existing filename

if IsObj($oExcelDoc) then

; Tip: Uncomment these lines to make Excel visible (credit: DaleHohm)
; $oExcelDoc.Windows(1).Visible = 1; Set the first worksheet in the workbook visible
; $oExcelDoc.Application.Visible = 1; Set the application visible (without this Excel will exit)

$String = "" ; String for displaying purposes

; Some document properties do not return a value, we will ignore those.
$OEvent=ObjEvent("AutoIt.Error","nothing"); Equal to VBscript's On Error Resume Next

For $Property In $oExcelDoc.BuiltinDocumentProperties
$String = $String & $Property.Name & ":" & $Property.Value & @CRLF
Next

Msgbox(0,"Excel File Test","The document properties of " & $FileName & " are:" & @CRLF & @CRLF & $String)

$oExcelDoc.Close ; Close the Excel document

else
Msgbox (0,"Excel File Test","Error: Could not open "& $FileName & " as an Excel Object.")
endif


Function ObjName

Function Reference

ObjName

Returns the name or interface description of an Object

ObjName ( $Objectvariable [,Flag] )

Parameters

$Objectvariable | A variable containing an Object whose name you want to retrieve
Flag | 1 = Name of the dispatch interface being used (default) 2 = Description of the (document) Object 3 = The ProgID of the Object 4 = The DLL file from with the Object was created (if supported) 5 = Filename and position of the toolbox icon (if supported)

Return Value

Success: | Returns a string representing the name
Failure: | Sets @error and Returns ""

Remarks

Not all Objects support flags 2 to 5. Always test for @error in these cases.

Related

IsObj, ObjGet, ObjCreate

Example

$oInternet = ObjCreate("InternetExplorer.Application")
$oInternet.Navigate( "http://www.google.com" ) ; Opening a web page that contains a form
sleep(4000) ; Give the page time to load

$oDoc = $oInternet.document ; Example object to test
$oForm = $oDoc.forms(0) ; Example object to test

msgbox(0,"","Interface name of $oInternet is: " & ObjName($oInternet) & @CRLF & _
"Object name of $oInternet is: " & ObjName($oInternet,2) & @CRLF & _
"Interface name of $oDoc is: " & ObjName($oDoc) & @CRLF & _
"Object name of $oDoc is: " & ObjName($oDoc,2) & @CRLF & _
"Interface name of $oForm is: " & ObjName($oForm) & @CRLF & _
"Object name of $oForm is: " & ObjName($oForm,2))


Function ProcessClose

Function Reference

ProcessClose

Terminates a named process.

ProcessClose ( "process" [, flag] )

Parameters

process | The title or PID of the process to terminate.
flag | [optional] if different from zero will force closing of handles to child stream if any defined in the Run() execution. process must be defined as a PID.

Return Value

None.

Remarks

Process names are executables without the full path, e.g., "notepad.exe" or "winword.exe"

If multiple processes have the same name, the one with the highest PID is terminated--regardless of how recently the process was spawned.

PID is the unique number which identifies a Process. A PID can be obtained through the ProcessExists or Run commands.

In order to work under Windows NT 4.0, ProcessClose requires the file PSAPI.DLL (included in the AutoIt installation directory).

The process is polled approximately every 250 milliseconds.

Related

ProcessExists, ProcessWait, ProcessWaitClose, Run, WinClose

Example

ProcessClose("notepad.exe")

$PID = ProcessExists("notepad.exe") ; Will return the PID or 0 if the process isn't found.
If $PID Then ProcessClose($PID)


Function ProcessExists

Function Reference

ProcessExists

Checks to see if a specified process exists.

ProcessExists ( "process" )

Parameters

process The name or PID of the process to check.

Return Value

Success: | Returns the PID of the process.
Failure: | Returns 0 if process does not exist.

Remarks

Process names are executables without the full path, e.g., "notepad.exe" or "winword.exe"

PID is the unique number which identifies a Process.

In order to work under Windows NT 4.0, ProcessExists requires the file PSAPI.DLL (included in the AutoIt installation directory).

The process is polled approximately every 250 milliseconds.

Related

ProcessClose, ProcessWait, ProcessWaitClose, WinExists

Example

If ProcessExists("notepad.exe") Then
MsgBox(0, "Example", "Notepad is running.")
EndIf


Function ProcessWait

Function Reference

ProcessWait

Pauses script execution until a given process exists.

ProcessWait ( "process" [, timeout] )

Parameters

process | The name of the process to check.
timeout | [optional] Specifies how long to wait (in seconds). Default is to wait indefinitely.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if the wait timed out.

Remarks

Process names are executables without the full path, e.g., "notepad.exe" or "winword.exe"

In order to work under Windows NT 4.0, ProcessWait requires the file PSAPI.DLL (included in the AutoIt installation directory).

The process is polled approximately every 250 milliseconds.

This function is the only process function not to accept a PID. Because PIDs are allocated randomly, waiting for a particular PID to exist doesn't make sense.

Related

ProcessClose, ProcessExists, ProcessWaitClose, RunWait, WinWait, WinWaitActive

Example

ProcessWait("notepad.exe")


Function ProcessWaitClose

Function Reference

ProcessWaitClose

Pauses script execution until a given process does not exist.

ProcessWaitClose ( "process" [, timeout] )

Parameters

process | The name or PID of the process to check.
timeout | [optional] Specifies how long to wait (in seconds). Default is to wait indefinitely.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if wait timed out.

Remarks

Process names are executables without the full path, e.g., "notepad.exe" or "winword.exe"

PID is the unique number which identifies a Process. A PID can be obtained through the ProcessExists or Run commands.

In order to work under Windows NT 4.0, ProcessWaitClose requires the file PSAPI.DLL (included in the AutoIt installation directory).

The process is polled approximately every 250 milliseconds.

Related

ProcessClose, ProcessExists, ProcessWait, RunWait, WinWaitClose

Example

;waits until no instance of notepad.exe exists
ProcessWaitClose("notepad.exe")

; This will wait until this particular instance of notepad has exited
$PID = Run("notepad.exe")
ProcessWaitClose($PID)


Function Round

Function Reference

Round

Returns a number rounded to a specified number of decimal places.

Round ( expression [, decimalplaces] )

Parameters

expression | Any valid numeric expression.
decimalplaces | [optional] Number indicating how many places to the right of the decimal are included in the rounding. If omitted, Round returns an integer.

Return Value

Returns rounded number.

Remarks

The decimalplaces parameter can be negative which allows you to round to the ones, tens, hundred, etc. place. Note that up to fifteen digits of a number are displayed, and note that decimalplaces will never pad a number with trailing zeros.

Related

Int, Number

Example

$x = Round(-1.582, 1) ;returns -1.6
$y = Round(3.1415, 9) ;no change
$z = round(123.5, -1) ;returns 120


Function Run

Function Reference

Run

Runs an external program.

Run ( "filename" [, "workingdir" [, flag[, standard_i/o_flag]]] )

Parameters

filename | The name of the executable (EXE, BAT, COM, or PIF) to run.
workingdir | [optional] The working directory.
flag | [optional] The "show" flag of the executed program: @SW_HIDE = Hidden window @SW_MINIMIZE = Minimized window @SW_MAXIMIZE = Maximized window
standard_i/o_flag | [optional] Provide a meaningful handle to one or more STD I/O streams of the child process. 1 ($STDIN_CHILD) = Provide a handle to the child's STDIN stream 2 ($STDOUT_CHILD) = Provide a handle to the child's STDOUT stream 4 ($STDERR_CHILD) = Provide a handle to the child's STDERR stream

Return Value

Success: | The PID of the process that was launched.
Failure: | Depends on RunErrorsFatal; see Remarks.

Remarks

To run DOS (console) commands, try Run(@ComSpec & " /c " & 'commandName', "", @SW_HIDE)

After running the requested program the script continues. To pause execution of the script until the spawned program has finished use the RunWait function instead.

By default the script will terminate with a fatal error if the Run function fails. To set @error 1, @extended to GetLastError() Windows API and return 0 as an indication of failure, see AutoItSetOption.

Providing the Standard I/O parameter with the proper values permits interaction with the child process through the StderrRead, StdinWrite and StdoutRead functions. Combine the flag values (or use $STDERR_CHILD, $STDIN_CHILD & $STDOUT_CHILD, defined in Constants.au3) to manage more than one stream.
Cleaning of defined streams can be done with ProcessClose().

Related

RunAsSet, RunErrorsFatal (Option), RunWait, ShellExecute, ShellExecuteWait, StderrRead, StdinWrite, StdoutRead, ProcessClose

Example

Run("Notepad.exe", "", @SW_MAXIMIZE)


Function RunAsSet

Function Reference

RunAsSet

Initialise a set of user credentials to use during Run and RunWait operations. 2000/XP or later ONLY.

RunAsSet ( ["user", "domain", "password" [, options]] )

Parameters

username | [optional] The user name to use.
domain | [optional] The domain name to use.
password | [optional] The password to use.
options | [optional] 0 = do not load the user profile, 1 = (default) load the user profile, 2 = use for net credentials only

Return Value

Success: | Returns 1--regardless of success. (If the login information was invalid, subsequent Run/RunWait commands will fail....)
Failure: | Returns 0 if the operating system does not support this function.

Remarks

This function allows subsequent Run and RunWait functions to run as a different user (e.g. Administrator). The function only works on the 2000/XP (or later) platforms. NT4 users should install and use the SU command from the NT Resource Kit.

The "Secondary Logon service" or "RunAs service" must not be disabled if you want this function to work.

To unset the RunAs details, use the function with no parameters: RunAsSet().

Related

Run, RunErrorsFatal (Option), RunWait

Example

; This example will rerun itself with admin rights on using a local account
; Note on Vista this may not work as even though the user is admin it may
; not be elevated even after the RunAs call. In that case use #RequireAdmin
; at the top of the script.

; Are we already admin?
If Not IsAdmin() Then
RunAsSet('USER', @Computername, 'PASSWORD')
Run('"' & @AutoItExe & '"' & ' "' & @ScriptFullPath & '"', @WorkingDir)
Exit
EndIf

MsgBox(0, 'Message', 'Now running with admin rights.')


Function RunWait

Function Reference

RunWait

Runs an external program and pauses script execution until the program finishes.

RunWait ( "filename" [, "workingdir" [, flag]] )

Parameters

filename | The name of the executable (EXE, BAT, COM, PIF) to run.
workingdir | [optional] The working directory.
flag | [optional] The "show" flag of the executed program: @SW_HIDE = Hidden window @SW_MINIMIZE = Minimized window @SW_MAXIMIZE = Maximized window

Return Value

Success: | Returns the exit code of the program that was run.
Failure: | Depends on RunErrorsFatal; see Remarks.

Remarks

To run DOS commands, try RunWait(@ComSpec & " /c " & "commandName")

After running the requested program the script pauses until the program terminates. To run a program and then immediately continue script execution use the Run function instead.

Some programs will appear to return immediately even though they are still running; these programs spawn another process - you may be able to use the ProcessWaitClose function to handle these cases.

By default the script will terminate with a fatal error if the Run function fails. To set @error to 1 as an indication of failure, see AutoItSetOption.

Related

ProcessWait, ProcessWaitClose, RunAsSet, RunErrorsFatal (Option), Run, ShellExecute, ShellExecuteWait

Example

$val = RunWait("Notepad.exe", @WindowsDir, @SW_MAXIMIZE)
; script waits until Notepad closes
MsgBox(0, "Program returned with exit code:", $val)


Function Send

Function Reference

Send

Sends simulated keystrokes to the active window.

Send ( "keys" [, flag] )

Parameters

keys | The sequence of keys to send.
flag | [optional] Changes how "keys" is processed: flag = 0 (default), Text contains special characters like + and ! to indicate SHIFT and ALT key-presses. flag = 1, keys are sent raw.

Return Value

None.

Remarks

See the Appendix for some tips on using Send. AutoIt can send all ASCII and Extended ASCII characters (0-255), to send UNICODE characters you must use the "ASC" option and the code of the character you wish to send (see {ASC} at the bottom of the table below).

The "Send" command syntax is similar to that of ScriptIt and the Visual Basic "SendKeys" command. Characters are sent as written with the exception of the following characters:

'!'
This tells AutoIt to send an ALT keystroke, therefore Send("This is text!a") would send the keys "This is text" and then press "ALT+a".

N.B. Some programs are very choosy about capital letters and ALT keys, i.e. "!A" is different to "!a". The first says ALT+SHIFT+A, the second is ALT+a. If in doubt, use lowercase!

'+'
This tells AutoIt to send a SHIFT keystroke, therefore Send("Hell+o") would send the text "HellO". Send("!+a") would send "ALT+SHIFT+a".

'^'
This tells AutoIt to send a CONTROL keystroke, therefore Send("^!a") would send "CTRL+ALT+a".

N.B. Some programs are very choosy about capital letters and CTRL keys, i.e. "^A" is different to "^a". The first says CTRL+SHIFT+A, the second is CTRL+a. If in doubt, use lowercase!

'#'
The hash now sends a Windows keystroke; therefore, Send("#r") would send Win+r which launches the Run dialog box.

You can set SendCapslockMode to make CAPS LOCK disabled at the start of a Send operation and restored upon completion.
However, if a user is holding down the Shift key when a Send function begins, text may be sent in uppercase.
One workaround is to Send("{SHIFTDOWN}{SHIFTUP}") before the other Send operations.

Certain keyboard as the Czech one send different characters when using the Shift Key or being in CAPS LOCK enabled and sending a char. Due to the send AutoIt implementation the CAPS LOCKed char will be sent as Shifted one so it will not work.

Certain special keys can be sent and should be enclosed in braces:

N.B. Windows does not allow the simulation of the "CTRL-ALT-DEL" combination!
Send Command (if zero flag) | Resulting Keypress
{!} | !
{#} | #
{+} | +
{^} | ^
{{} | {
{}} | }
{SPACE} | SPACE
{ENTER} | ENTER key on the main keyboard
{ALT} | ALT
{BACKSPACE} or {BS} | BACKSPACE
{DELETE} or {DEL} | DELETE
{UP} | Up arrow
{DOWN} | Down arrow
{LEFT} | Left arrow
{RIGHT} | Right arrow
{HOME} | HOME
{END} | END
{ESCAPE} or {ESC} | ESCAPE
{INSERT} or {INS} | INS
{PGUP} | PageUp
{PGDN} | PageDown
{F1} - {F12} | Function keys
{TAB} | TAB
{PRINTSCREEN} | Print Screen key
{LWIN} | Left Windows key
{RWIN} | Right Windows key
{NUMLOCK on} | NUMLOCK (on/off/toggle)
{CAPSLOCK off} | CAPSLOCK (on/off/toggle)
{SCROLLLOCK toggle} | SCROLLLOCK (on/off/toggle)
{BREAK} | for Ctrl+Break processing
{PAUSE} | PAUSE
{NUMPAD0} - {NUMPAD9} | Numpad digits
{NUMPADMULT} | Numpad Multiply
{NUMPADADD} | Numpad Add
{NUMPADSUB} | Numpad Subtract
{NUMPADDIV} | Numpad Divide
{NUMPADDOT} | Numpad period
{NUMPADENTER} | Enter key on the numpad
{APPSKEY} | Windows App key
{LALT} | Left ALT key
{RALT} | Right ALT key
{LCTRL} | Left CTRL key
{RCTRL} | Right CTRL key
{LSHIFT} | Left Shift key
{RSHIFT} | Right Shift key
{SLEEP} | Computer SLEEP key
{ALTDOWN} | Holds the ALT key down until {ALTUP} is sent
{SHIFTDOWN} | Holds the SHIFT key down until {SHIFTUP} is sent
{CTRLDOWN} | Holds the CTRL key down until {CTRLUP} is sent
{LWINDOWN} | Holds the left Windows key down until {LWINUP} is sent
{RWINDOWN} | Holds the right Windows key down until {RWINUP} is sent
{ASC nnnn} | Send the ALT+nnnn key combination
{BROWSER_BACK} | 2000/XP Only: Select the browser "back" button
{BROWSER_FORWARD} | 2000/XP Only: Select the browser "forward" button
{BROWSER_REFRESH} | 2000/XP Only: Select the browser "refresh" button
{BROWSER_STOP} | 2000/XP Only: Select the browser "stop" button
{BROWSER_SEARCH} | 2000/XP Only: Select the browser "search" button
{BROWSER_FAVORITES} | 2000/XP Only: Select the browser "favorites" button
{BROWSER_HOME} | 2000/XP Only: Launch the browser and go to the home page
{VOLUME_MUTE} | 2000/XP Only: Mute the volume
{VOLUME_DOWN} | 2000/XP Only: Reduce the volume
{VOLUME_UP} | 2000/XP Only: Increase the volume
{MEDIA_NEXT} | 2000/XP Only: Select next track in media player
{MEDIA_PREV} | 2000/XP Only: Select previous track in media player
{MEDIA_STOP} | 2000/XP Only: Stop media player
{MEDIA_PLAY_PAUSE} | 2000/XP Only: Play/pause media player
{LAUNCH_MAIL} | 2000/XP Only: Launch the email application
{LAUNCH_MEDIA} | 2000/XP Only: Launch media player
{LAUNCH_APP1} | 2000/XP Only: Launch user app1
{LAUNCH_APP2} | 2000/XP Only: Launch user app2

To send the ASCII value A (same as pressing ALT+065 on the numeric keypad)
Send("{ASC 065}")

(When using 2 digit ASCII codes you must use a leading 0, otherwise an obsolete 437 code page is used).

To send UNICODE characters enter the character code (decimal or hex), for example this sends a Chinese character
Send("{ASC 2709}") or Send("{ASC 0xA95}")

Single keys can also be repeated, e.g.
Send("{DEL 4}") ;Presses the DEL key 4 times
Send("{S 30}") ;Sends 30 'S' characters
Send("+{TAB 4}") ;Presses SHIFT+TAB 4 times

The key will be send at least once even if the count is zero.

To hold a key down (generally only useful for games)
Send("{a down}") ;Holds the A key down
Send("{a up}") ;Releases the A key

To set the state of the capslock, numlock and scrolllock keys
Send("{NumLock on}") ;Turns the NumLock key on
Send("{CapsLock off}") ;Turns the CapsLock key off
Send("{ScrollLock toggle}") ;Toggles the state of ScrollLock

If you wish to use a variable for the count, try
$n = 4
Send("+{TAB " & $n & "}")

If you wish to send the ASCII value A four times, then try
$x = Chr(65)
Send("{" & $x & " 4}")

Most laptop computer keyboards have a special Fn key. This key cannot be simulated.

Note, by setting the flag parameter to 1 the above "special" processing will be disabled. This is useful when you want to send some text copied from a variable and you want the text sent exactly as written.

For example, open Folder Options (in the control panel) and try the following:
Send("{TAB}") | Navigate to next control (button, checkbox, etc)
Send("+{TAB}") | Navigate to previous control.
Send("^{TAB}") | Navigate to next WindowTab (on a Tabbed dialog window)
Send("^+{TAB}") | Navigate to previous WindowTab.
Send("{SPACE}") | Can be used to toggle a checkbox or click a button.
Send("{+}") | Usually checks a checkbox (if it's a "real" checkbox.)
Send("{-}") | Usually unchecks a checkbox.
Send("{NumPadMult}") | Recursively expands folders in a SysTreeView32.

Use Alt-key combos to access menu items. Also, open Notepad and try the following:
Send("!f") Send Alt+f, the access key for Notepad's file menu. Try other letters!

Send("{DOWN}") | Move down a menu.
Send("{UP}") | Move up a menu.
Send("{LEFT}") | Move leftward to new menu or expand a submenu.
Send("{RIGHT}") | Move rightward to new menu or collapse a submenu.
See Windows' Help--press Win+F1--for a complete list of keyboard shortcuts if you don't know the importance of Alt+F4, PrintScreen, Ctrl+C, and so on.

When running a script on a remote computer through a program as psexec (www.sysinternals.com) or beyondexec (www.beyondlogic.org) it is necessary, specially when sending strokes to a program launch by the script with a Run function, to use ControlSend or other ControlXXX functions to directly communicate with the control. Send even with Opt("SendAttachMode",1) is not working.
Using the -s mode when submitting can help to have better right on the remote computer.

Opt("SendKeyDelay",...) alters the the length of the brief pause in between sent keystrokes.
Opt("SendKeyDownDelay",...) alters the length of time a key is held down before being released during a keystroke.

Related

SendAttachmode (Option), SendKeyDelay (Option), SendKeyDownDelay (Option), ControlSend

Example

Send("#r")
WinWaitActive("Run")
Send("notepad.exe{Enter}")
WinWaitActive("Untitled -")
Send("Today's time/date is {F5}")


Function ShellExecute

Function Reference

ShellExecute

Runs an external program using the ShellExecute API.

ShellExecute ( "filename" [, "parameters" [, "workingdir" [, "verb" [, showflag]]]] )

Parameters

filename | The name of the file to run (EXE, .txt, .lnk, etc).
parameters | [optional] Any parameters for the program. Blank ("") uses none.
workingdir | [optional] The working directory. Blank ("") uses the current working directory.
verb | [optional] The "verb" to use, common verbs include: open = (default) Opens the file specified. The file can be an executable file, a document file, or a folder edit = Launches an editor and opens the document for editing. If "filename" is not a document file, the function will fail print = Prints the document file specified. If "filename" is not a document file, the function will fail properties = Displays the file or folder's properties
showflag | [optional] The "show" flag of the executed program: @SW_HIDE = Hidden window @SW_MINIMIZE = Minimized window @SW_MAXIMIZE = Maximized window

Return Value

Success: | Returns 1.
Failure: | Depends on RunErrorsFatal; see Remarks.

Remarks

After running the requested program the script continues. To pause execution of the script until the spawned program has finished use the ShellExecuteWait function instead.

By default the script will terminate with a fatal error if the ShellExecute function fails. To set @error to 1 as an indication of failure, see AutoItSetOption.

Related

ShellExecuteWait, Run, RunErrorsFatal (Option), RunWait

Example

; Open Notepad
ShellExecute("Notepad.exe")

; Open a .txt file with it's default editor
ShellExecute("myfile.txt", "", @ScriptDir, "edit")


Function ShellExecuteWait

Function Reference

ShellExecuteWait

Runs an external program using the ShellExecute API and pauses script execution until it finishes.

ShellExecuteWait ( "filename" [, "parameters" [, "workingdir" [, "verb" [, showflag]]]] )

Parameters

filename | The name of the file to run (EXE, .txt, .lnk, etc).
parameters | [optional] Any parameters for the program. Blank ("") uses none.
workingdir | [optional] The working directory. Blank ("") uses the current working directory.
verb | [optional] The "verb" to use, common verbs include: open = (default) Opens the file specified. The file can be an executable file, a document file, or a folder edit = Launches an editor and opens the document for editing. If "filename" is not a document file, the function will fail print = Prints the document file specified. If "filename" is not a document file, the function will fail properties = Displays the file or folder's properties
showflag | [optional] The "show" flag of the executed program: @SW_HIDE = Hidden window @SW_MINIMIZE = Minimized window @SW_MAXIMIZE = Maximized window

Return Value

Success: | Returns the exit code of the program that was run.
Failure: | Depends on RunErrorsFatal; see Remarks.

Remarks

After running the requested program the script pauses until the requested program terminates

By default the script will terminate with a fatal error if the ShellExecute function fails. To set @error to 1 as an indication of failure, see AutoItSetOption.

Related

ShellExecute, Run, RunErrorsFatal (Option), RunWait

Example

$val = ShellExecuteWait("Notepad.exe")

; script waits until Notepad closes
MsgBox(0, "Program returned with exit code:", $val)


Function StatusbarGetText

Function Reference

StatusbarGetText

Retrieves the text from a standard status bar control.

StatusbarGetText ( "title" [, "text" [, part]] )

Parameters

title | The title of the window to check.
text | [optional] The text of the window to check.
part | [optional] The "part" number of the status bar to read - the default is 1. 1 is the first possible part and usually the one that contains the useful messages like "Ready" "Loading...", etc.

Return Value

Success: | Returns the text read.
Failure: | Returns "" (blank string) and sets @error to 1 if no text could be read.

Remarks

This functions attempts to read the first standard status bar on a window (Microsoft common control: msctls_statusbar32). Some programs use their own status bars or special versions of the MS common control which StatusbarGetText cannot read. For example, StatusbarText does not work on the program TextPad; however, the first region of TextPad's status bar can be read using ControlGetText("TextPad", "", "HSStatusBar1")
StatusbarGetText can work on windows that are minimized or even hidden.

Related

ControlGetText, ControlCommand

Example

AutoItSetOption("WinTitleMatchMode", 2)
$x = StatusbarGetText("Internet Explorer")
MsgBox(0, "Internet Explorer's status bar says:", $x)


Function StderrRead

Function Reference

StderrRead

Read in a number of characters from the STDERR stream of a previously run child process.

StderrRead ( process_id[, count[, peek = false]] )

Parameters

process_id | The process ID of a child process, as returned by a previous call to Run.
count | The number of characters to read.
peek | If true the function does not remove the read characters from the stream.

Return Value

Success: | Returns a string of the characters read.
Failure: | Sets @error to non-zero if EOF is reached, STDERR was not redirected for the process or other error.

Remarks

StderrRead reads from the console standard error stream of a child process, which is normally used by console applications to write errors to the screen. During the call to Run for the child process you wish to read from, the STD I/O parameter must have included the STDERR flag value (4) for this function to work properly (see the Run function).

The optional second parameter tells StderrRead to read count characters from the stream. If fewer than count characters are available, StderrRead returns a string of all the characters that are available at that time. If the function is called with no second argument or a second argument of less than zero, StderrRead assumes you that you wish to read the maximum number of characters and returns a string of all the characters that are available (up to 64kb in a single read).

If at any time when this function is called (except for "peeking" as described below) there are no characters to be read from the stream, the StderrRead function will block (pause) and not return until there are characters to be read from the stream. This means that the AutoIt process will be halted, and there will be no processing of hotkeys, GUI messages, etc. until the child process writes something to the STDERR stream.

If StderrRead is called with a third argument other than zero, StderrRead will "peek at" the stream rather than actually reading from it, and return the characters that could be read from the stream. When run as a "peek" StderrRead always returns immediately. Note that any characters are still present on the stream after a peek and will be returned on the next read operation.

When called with a second argument of 0 and a third argument that directs the function to "peek", StderrRead returns a numeric value of the number of characters that could currently be read from the stream.

Streams of child processes run with RunAsSet cannot be read from at this time.

Related

StdoutRead, StdinWrite, Run

Example

; Demonstrates StdoutRead()
#include <Constants.au3>

$foo = Run(@ComSpec & " /c dir foo.bar", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

While 1
$line = StdoutRead($foo)
If @error Then ExitLoop
MsgBox(0, "STDOUT read:", $line)
Wend

While 1
$line = StderrRead($foo)
If @error Then ExitLoop
MsgBox(0, "STDERR read:", $line)
Wend

MsgBox(0, "Debug", "Exiting...")


Function StdinWrite

Function Reference

StdinWrite

Writes a number of characters to the STDIN stream of a previously run child process.

StdinWrite ( process_id[, string] )

Parameters

process_id | The process ID of a child process, as returned by a previous call to Run.
string | String of characters to write.

Return Value

Success: | Returns the number of characters written.
Failure: | Sets @error to -1 if STDIN was not redirected for the process or other error.

Remarks

StdinWrite writes to the console standard input stream for a child process, which is normally used by console applications to read input from the user i.e. from the keyboard. During the call to Run for the child process you wish to write to the STD I/O parameter must have included the value of $Stdin_Child for this function to work properly.

The optional second parameter is the string that you wish StdinWrite to write to the stream. If the function is called with no second argument, StdinWrite closes the stream and invalidates it for further writing.

The stream is a first-in first-out buffer with an arbitrary limited size; if at any time when this function is called (unless it's being called to close the stream) there is no room for more characters to be written to the stream, the StdinWrite function will block (pause) and not return until the child process closes the stream or reads enough characters from the stream to permit the write procedure to complete. This means that the AutoIt process will be halted, and there will be no processing of hotkeys, GUI messages, etc. until the child process reads from the STDIN stream.

Streams of child processes run with RunAsSet cannot be written to at this time.

Related

StdoutRead, StderrRead, Run

Example

; Demonstrates the use of StdinWrite()
#include <Constants.au3>

$foo = Run("sort.exe", @SystemDir, @SW_HIDE, $STDIN_CHILD + $STDOUT_CHILD)
; Write string to be sorted to child sort.exe's STDIN
StdinWrite($foo, "rat" & @CRLF & "cat" & @CRLF & "bat" & @CRLF)
; Calling with no 2nd arg closes stream
StdinWrite($foo)

; Read from child's STDOUT and show
MsgBox(0, "Debug", StdoutRead($foo))


Function StdoutRead

Function Reference

StdoutRead

Reads in a number of characters from the STDOUT stream of a previously run child process.

StdoutRead ( process_id[, count[, peek = false]] )

Parameters

process_id | The process ID of a child process, as returned by a previous call to Run.
count | The number of characters to read.
peek | If true the function does not remove the read characters from the stream.

Return Value

Success: | Returns a string of the characters read.
Failure: | Sets @error to non-zero if EOF is reached, STDOUT was not redirected for the process or other error.

Remarks

StdoutRead reads from the console standard output stream of a child process, which is normally used by console applications to write to the screen. During the call to Run for the child process you wish to read from the STD I/O parameter must have included the STDOUT flag value (2) for this function to work properly (see the Run function).

The optional second parameter tells StdoutRead to read count characters from the stream. If fewer than count characters are available, StdoutRead returns a string of all the characters that are available at that time. If the function is called with no second argument or a second argument of less than zero, StdoutRead assumes you that you wish to read the maximum number of characters and returns a string of all the characters that are available (up to 64kb in a single read).

If at any time when this function is called (except for "peeking" as described below) there are no characters to be read from the stream, the StdoutRead function will block (pause) and not return until there are characters to be read from the stream. This means that the AutoIt process will be halted, and there will be no processing of hotkeys, GUI messages, etc. until the child process writes something to the STDOUT stream.

If StdoutRead is called with a third argument other than zero, StdoutRead will "peek at" the stream rather than actually reading from it, and return the characters that could be read from the stream. When run as a "peek" StdoutRead always returns immediately. Note that any characters are still present on the stream after a peek and will be returned on the next read operation.

When called with a second argument of 0 and a third argument that directs the function to "peek", StdoutRead returns a numeric value of the number of characters that could currently be read from the stream.

Streams of child processes run with RunAsSet cannot be read from at this time.

Related

StderrRead, StdinWrite, Run

Example

; Demonstrates StdoutRead()
#include <Constants.au3>

$foo = Run(@ComSpec & " /c dir foo.bar", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

While 1
$line = StdoutRead($foo)
If @error Then ExitLoop
MsgBox(0, "STDOUT read:", $line)
Wend

While 1
$line = StderrRead($foo)
If @error Then ExitLoop
MsgBox(0, "STDERR read:", $line)
Wend

MsgBox(0, "Debug", "Exiting...")


Function String

Function Reference

String

Returns the string representation of an expression.

String ( expression )

Parameters

expression An expression to convert into a string.

Return Value

Returns a string.

Remarks

Maximum string length is 2147483647 characters (but keep in mind that no line in an AutoIt script can exceed 4095 characters.)

Related

Int, Number, IsString, Chr

Example

$var = String(10)
;$var is the string "10"


Function StringCompare

Function Reference

StringCompare

Compares two strings with options.

StringCompare ( "string1", "string2" [, casesense] )

Parameters

string1 | The first string to evaluate.
string2 | The second string to evaluate.
casesense | [optional] Flag to indicate if the operations should be case sensitive. 0 = not case sensitive, using the user's locale (default) 1 = case sensitive 2 = not case sensitive, using a basic/faster comparison

Return Value

0 | string1 and string2 are equal
> 0 | string1 is greater than string2
< 0 | string1 is less than string2

Remarks

None.

Related

String, StringInStr, StringLeft, StringLen, StringLower, StringMid, StringRight, StringTrimLeft, StringTrimRight, StringUpper

Example

$result = StringCompare("MELÓN", "melón")
MsgBox(0, "StringCompare Result (mode 0):", $result)

$result = StringCompare("MELÓN", "melón", 1)
MsgBox(0, "StringCompare Result (mode 1):", $result)

$result = StringCompare("MELÓN", "melón", 2)
MsgBox(0, "StringCompare Result (mode 2):", $result)


Function StringInStr

Function Reference

StringInStr

Checks if a string contains a given substring.

StringInStr ( "string", "substring" [, casesense [, occurrence]] )

Parameters

string | The string to evaluate.
substring | The substring to search for.
casesense | [optional] Flag to indicate if the operations should be case sensitive. 0 = not case sensitive, using the user's locale (default) 1 = case sensitive 2 = not case sensitive, using a basic/faster comparison
occurrence | [optional] Which occurrence of the substring to find in the string. Use a negative occurrence to search from the right side. The default value is 1 (finds first occurrence).

Return Value

Success: | Returns the position of the substring.
Failure: | Returns 0 if substring not found.
@Error | 0 - Normal operation
 | 1 - Occurrence was 0. Occurrence must be a positive or negative integer.

Remarks

The first character position is 1. If occurrence is given, casesense must also be given.

Related

String, StringCompare, StringLeft, StringLen, StringLower, StringMid, StringRight, StringTrimLeft, StringTrimRight, StringUpper

Example

$result = StringInStr("I am a String", "RING")
MsgBox(0, "Search result:", $result)

$location = StringInStr("How much wood could a woodchuck chuck is a woodchuck could chuck wood?", "wood", 0, 3) ; Find the 3rd occurance of "wood"


Function StringIsAlNum

Function Reference

StringIsAlNum

Checks if a string contains only alphanumeric characters.

StringIsAlNum ( "string" )

Parameters

string The string to check

Return Value

Success: | Returns 1.
Failure: | Returns 0 if string contains non-alphanumeric characters.

Remarks

Keep in mind that any whitespace will cause StringIsAlNum to return 0.

Related

StringIsAlpha, StringIsASCII, StringIsDigit, StringIsLower, StringIsSpace, StringIsUpper, StringIsXDigit, StringUpper, StringLower

Example

$x = "This is a sentence with whitespace."
MsgBox(0,"StringIsAlNum returns:", StringIsAlNum($x))


Function StringIsAlpha

Function Reference

StringIsAlpha

Checks if a string contains only alphabetic characters.

StringIsAlpha ( "string" )

Parameters

string The string to check

Return Value

Success: | Returns 1.
Failure: | Returns 0 if string contains non-alphabetic characters.

Remarks

Keep in mind that any whitespace will cause StringIsAlpha to return 0.

Related

StringIsAlNum, StringIsASCII, StringIsDigit, StringIsLower, StringIsSpace, StringIsUpper, StringIsXDigit, StringUpper, StringLower

Example

$x = "This is a sentence with whitespace."
MsgBox(0,"StringIsAlpha returns:", StringIsAlpha($x))


Function StringIsASCII

Function Reference

StringIsASCII

Checks if a string contains only ASCII characters in the range 0x00 - 0x7f (0 - 127).

StringIsASCII ( "string" )

Parameters

string The string to check

Return Value

Success: | Returns 1.
Failure: | Returns 0 if string contains extended ASCII characters.

Remarks

None.

Related

StringIsAlNum, StringIsAlpha, StringIsDigit, StringIsLower, StringIsSpace, StringIsUpper, StringIsXDigit, StringUpper, StringLower

Example

$x = StringIsASCII("This is a sentence.")
MsgBox(0,"StringIsASCII returns:", $x)


Function StringIsDigit

Function Reference

StringIsDigit

Checks if a string contains only digit (0-9) characters.

StringIsDigit ( "string" )

Parameters

string The string to check

Return Value

Success: | Returns 1.
Failure: | Returns 0 if string contains non-digits.

Remarks

See examples.

Related

StringIsAlNum, StringIsAlpha, StringIsASCII, StringIsLower, StringIsSpace, StringIsUpper, StringIsXDigit

Example

StringIsDigit("12333") ;returns 1
StringIsDigit("1.5") ;returns 0 due to decimal point
StringIsDigit("1 2 3") ;returns 0 due to whitespace
StringIsDigit("") ;returns 0


Function StringIsFloat

Function Reference

StringIsFloat

Checks if a string is a floating point number.

StringIsFloat ( "string" )

Parameters

string The string or expression to check.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if not floating point format.

Remarks

A string is a float if it contains at least one decimal digit and exactly one period; the only other character allowed is an optional plus or minus at the beginning. (StringIsFloat does not accept a comma character as the decimal point even if the computer Locale settings use that symbol.) If parameter is not a string, its value is converted to a string. See examples.

Related

StringIsInt, IsFloat

Example

StringIsFloat("1.5") ;returns 1
StringIsFloat("7.") ;returns 1 since contains decimal
StringIsFloat("-.0") ;returns 1
StringIsFloat("3/4") ;returns 0 since '3' slash '4' is not a float
StringIsFloat("2") ; returns 0 since '2' is an interger, not a float

StringIsFloat(1.5) ;returns 1 since 1.5 converted to string contain .
StringIsFloat(1.0) ;returns 0 since 1.0 converted to string does not contain .


Function StringIsInt

Function Reference

StringIsInt

Checks if a string is an integer.

StringIsInt ( "string" )

Parameters

string The string to check.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if string cannot be an integer.

Remarks

StringIsInt also returns 1 for non-string integer expressions; however, StringIsInt returns 0 for hexadecimal expressions such as "4ff0". The only punctuation allowed is either a plus or a minus at the beginning of the string.

Related

StringIsFloat, StringIsDigit, IsInt

Example

StringIsInt("+42") ;returns 1
StringIsInt("-00") ;returns 1
StringIsInt("1.0") ;returns 0 due to the decimal point
StringIsInt(1.0) ;returns 1 due to number-string conversion
StringIsInt("1+2") ;returns 0 due to plus sign


Function StringIsLower

Function Reference

StringIsLower

Checks if a string contains only lowercase characters.

StringIsLower ( "string" )

Parameters

string The string to check

Return Value

Success: | Returns 1.
Failure: | Returns 0 if string contains non-lowercase characters.

Remarks

Note that digits/punctuation/whitespace will cause StringIsLower to return 0.

Related

StringIsAlNum, StringIsAlpha, StringIsASCII, StringIsDigit, StringIsSpace, StringIsUpper, StringIsXDigit, StringUpper, StringLower

Example

If StringIsLower("abcfoo") Then
MsgBox(0, "Result:", "String contained only lowercase letters")
EndIf


Function StringIsSpace

Function Reference

StringIsSpace

Checks if a string contains only whitespace characters.

StringIsSpace ( "string" )

Parameters

string The string to check

Return Value

Success: | Returns 1.
Failure: | Returns 0 if string contains non-whitespace characters.

Remarks

Whitespace includes Chr(9) thru Chr(13) which are HorizontalTab, LineFeed, VerticalTab, FormFeed, and CarriageReturn.

Whitespace also includes the standard space ( Chr(32) ).

Related

StringIsAlNum, StringIsAlpha, StringIsASCII, StringIsDigit, StringIsLower, StringIsUpper, StringIsXDigit, StringUpper, StringLower

Example

$x = " " & @LF & Chr(11) & @TAB & " " & @CRLF
If StringIsSpace($x) Then
MsgBox(0,"", "String only contained whitespace characters.")
EndIf


Function StringIsUpper

Function Reference

StringIsUpper

Checks if a string contains only uppercase characters.

StringIsUpper ( "string" )

Parameters

string The string to check

Return Value

Success: | Returns 1.
Failure: | Returns 0 if string contains non-uppercase characters.

Remarks

Note that digits/punctuation/whitespace will cause StringIsUpper to return 0.

Related

StringIsAlNum, StringIsAlpha, StringIsASCII, StringIsDigit, StringIsLower, StringIsSpace, StringIsXDigit, StringUpper, StringLower

Example

If StringIsUpper("ABCDF") Then
MsgBox(4096, "", "String contains only UPPERCASE letters"
EndIf


Function StringIsXDigit

Function Reference

StringIsXDigit

Checks if a string contains only hexadecimal digit (0-9, A-F) characters.

StringIsXDigit ( "string" )

Parameters

string The string to check

Return Value

Success: | Returns 1.
Failure: | Returns 0 if string contains non-hexadecimal characters.

Remarks

Valid characters are 0123456789abcdefABCDEF Note that a string containing whitespace or the "0x" prefix will cause StringIsXDigit to return 0.

Related

StringIsAlNum, StringIsAlpha, StringIsASCII, StringIsDigit, StringIsLower, StringIsSpace, StringIsUpper, StringUpper, StringLower

Example

StringIsXDigit("00FC") ;returns 1
StringIsXDigit("2570") ;returns 1
StringIsXDigit("a cafe") ;returns 0 due to space
StringIsXDigit(1 + 2.0) ;returns 1 due to number-string conversion


Function StringLeft

Function Reference

StringLeft

Returns a number of characters from the left-hand side of a string.

StringLeft ( "string", count )

Parameters

string | The string to evaluate.
count | The number of characters to get.

Return Value

Returns a string containing the leftmost count characters of the string.

Remarks

If count exceeds string length, the entire string is returned.
If count is negative, an empty string is returned.

Related

String, StringInStr, StringLen, StringLower, StringMid, StringRight, StringTrimLeft, StringTrimRight, StringUpper

Example

$result = StringLeft("I am a string", 3)
MsgBox(0, "Leftmost 3 characters are:", $result)


Function StringLen

Function Reference

StringLen

Returns the number of characters in a string.

StringLen ( "string" )

Parameters

string The string to evaluate.

Return Value

Returns the length of the string.

Remarks

A numeric expression is automatically evaluated and converted to a string.

Related

String, StringInStr, StringLeft, StringLower, StringMid, StringRight, StringTrimLeft, StringTrimRight, StringUpper

Example

$len = StringLen("How long am I?")
MsgBox(0, "String length is:", $len)


Function StringLower

Function Reference

StringLower

Converts a string to lowercase.

StringLower ( "string" )

Parameters

string The string to convert.

Return Value

Returns the string converted to lowercase.

Remarks

None.

Related

StringIsLower, StringIsUpper, String, StringInStr, StringLeft, StringLen, StringMid, StringRight, StringTrimLeft, StringTrimRight, StringUpper

Example

$var = StringLower("I Am A String")
MsgBox(0, "String converted to lowercase is:", $var)


Function StringMid

Function Reference

StringMid

Extracts a number of characters from a string.

StringMid ( "string", start [, count] )

Parameters

string | The string to evaluate.
start | The character position to start. (1 = first character)
count | [optional] The number of characters to extract. By default the entire remainder of the string.

Return Value

Returns the extracted string.

Remarks

If start is out-of-bounds, an empty string is returned. If start is valid but count is out-of-bounds, the entire remainder of the string is returned.

Related

String, StringInStr, StringLeft, StringLen, StringLower, StringRight, StringTrimLeft, StringTrimRight, StringUpper

Example

$var = StringMid("I am a string", 3, 2)
MsgBox(0, "2 chars extracted from position 3 are:", $var)


Function StringRegExp

Function Reference

StringRegExp

Check if a string fits a given regular expression pattern.

StringRegExp ( "test", "pattern" [, flag ] [, offset ] ] )

Parameters

test | The string to check
pattern | The regular expression to compare.
flag | [optional] A number to indicate how the function behaves. See below for details. The default is 0.
offset | [optional] The string position to start the match (starts at 1) The default is 1.

Flag | Values
0 | Returns 1 (matched) or 0 (no match)
1 | Return array of matches.
2 | Return array of matches including the full match (Perl / PHP style).
3 | Return array of global matches.
4 | Return an array of arrays containing global matches including the full match (Perl / PHP style).

Return Value

Flag = 0 :
@Error | Meaning
2 | Bad pattern. @Extended = offset of error in pattern.

Flag = 1 or 2 :
@Error | Meaning
0 | Array is valid. Check @Extended for next offset
1 | Array is invalid. No matches.
2 | Bad pattern, array is invalid. @Extended = offset of error in pattern.

Flag = 3 or 4 :
@Error | Meaning
0 | Array is valid.
1 | Array is invalid. No matches.
2 | Bad pattern, array is invalid. @Extended = offset of error in pattern.

Remarks

Regular expression notation is a compact way of specifying a pattern for strings that can be searched. Regular expressions are character strings in which plain text characters indicate what text should exist in the target string, and a some characters are given special meanings to indicate what variability is allowed in the target string. AutoIt regular expressions are normally case-sensitive.

Regular expressions are constructed of one or more of the following simple regular expression specifiers. If the character is not in the following table, then it will match only itself.

Repeating characters (*, +, ?, {...} ) will try to match the largest set possible, which allows the following characters to match as well, unless followed immediately by a question mark; then it will find the smallest pattern that allows the following characters to match as well.

Nested groups are allowed, but keep in mind that all the groups, except non-capturing groups, assign to the returned array, with the outer groups assigning after the inner groups.

Complete description can be found here

Caution: bad regular expressions can produce a quasi infinite loop hogging the CPU even a crash.

Matching Characters

[ ... ] | Match any character in the set. e.g. [aeiou] matches any lower-case vowel. A contiguous set can be defined using a dash between the starting and ending characters. e.g. [a-z] matches any lower case character. To include a dash (-) in a set, use it as the first or last character of the set. To include a closing bracket in a set, use it as the first character of the set. e.g. [][] will match either [ or ]. Note that special characters do not retain their special meanings inside a set, with the exception of \\, \^, \-,\[ and \] match the escaped character inside a set.
[^ ... ] | Match any character not in the set. e.g. [^0-9] matches any non-digit. To include a caret (^) in a set, put it after the beginning of the set or escape it (\^).
[:class:] | Match a character in the given class of characters. Valid classes are: alpha (any alphabetic character), alnum (any alphanumeric character), lower (any lower-case letter), upper (any upper-case letter), digit (any decimal digit 0-9), xdigit (any hexadecimal digit, 0-9, A-F, a-f), space (any whitespace character), blank (only a space or tab), print (any printable character), graph (any printable character except spaces), cntrl (any control character [ascii 127 or <32]) or punct (any punctuation character). So [0-9] is equivalent to [[:digit:]].
[^:class:] | Match any character not in the class, but only if the first character.
( ... ) | Group. The elements in the group are treated in order and can be repeated together. e.g. (ab)+ will match "ab" or "abab", but not "aba". A group will also store the text matched for use in back-references and in the array returned by the function, depending on flag value.
(?i) | Case-insensitivity flag. This does not operate as a group. It tells the regular expression engine to do case-insensitive matching from that point on.
(?-i) | (default) Case-sensitivity flag. This does not operate as a group. It tells the regular expression engine to do case-sensitive matching from that point on.
(?i ... ) | Case-insensitive group. Behaves just like a normal group, but performs case-insensitive matches within the group.
(?-i ... ) | Case-sensitive group. Behaves just like a normal group, but performs case-sensitive matches within the group. Primarily for use after (-i) flag or inside a case-insensitive group.
(?: ... ) | Non-capturing group. Behaves just like a normal group, but does not record the matching characters in the array nor can the matched text be used for back-referencing.
(?i: ... ) | Case-insensitive non-capturing group. Behaves just like a non-capturing group, but performs case-insensitive matches within the group.
(?-i: ... ) | Case-sensitive non-capturing group. Behaves just like a non-capturing group, but performs case-sensitive matches within the group.
(?m) | ^ and $ match newlines within data.
(?s) | . matches anything including newline. (by default "." don't match newline)
(?x) | Ignore whitespace and # comments.
(?U) | Invert greediness of quantifiers.
. | Match any single character (except newline).
| | Or. The expression on one side or the other can be matched.
\ | Escape a special character (have it match the actual character) or introduce a special character type (see below).
\\ | Match an actual backslash (\).
\a | Alarm, that is, the BEL character (chr(7)).
\A | Match only at beginning of string.
\b | Matches at a word boundary.
\B | Matches when not at a word boundary.
\c | Match a control character, based on the next character. For example, \cM matches ctrl-M.
\d | Match any digit (0-9).
\D | Match any non-digit.
\e | Match an escape character (chr(27)).
\E | end case modification.
\f | Match an formfeed character (chr(12)).
\h | any horizontal whitespace character.
\H | any character that is not a horizontal whitespace character.
\l | Match lowercase next char.
\L | Match lowercase till \E.
\n | Match a linefeed (@LF, chr(10)).
\Q | quote (disable) pattern metacharacters till \E.
\r | Match a carriage return (@CR, chr(13)).
\s | Match any whitespace character: Chr(9) through Chr(13) which are Horizontal Tab, Line Feed, Vertical Tab, Form Feed, and Carriage Return, and the standard space ( Chr(32) ).
\S | Match any non-whitespace character.
\t | Match a tab character (chr(9)).
\u | Match uppercase next char.
\U | Match uppercase till \E.
\v | any vertical whitespace character.
\V | any character that is not a vertical whitespace character
. |
\w | Match any "word" character: a-z, A-Z or underscore (_).
\W | Match any non-word character.
\### | Match the ascii character whose code is given or back-reference. Can be up to 3 octal digits. Match back-reference if found. Match the prior group number given exactly. For example, ([:alpha:])\1 would match a double letter.
\x## | Match the ascii character whose code is given in hexadecimal. Can be up to 2 digits.
\z | Match only at end of string.
\Z | Match only at end of string, or before newline at the end.

Repeating Characters

{x} | Repeat the previous character, set or group exactly x times.
{x,} | Repeat the previous character, set or group at least x times.
{0,x} | Repeat the previous character, set or group at most x times.
{x, y} | Repeat the previous character, set or group between x and y times, inclusive.
* | Repeat the previous character, set or group 0 or more times. Equivalent to {0,}
+ | Repeat the previous character, set or group 1 or more times. Equivalent to {1,}
? | The previous character, set or group may or may not appear. Equivalent to {0, 1}
? (after a repeating character) | Find the smallest match instead of the largest.

Character Classes

[:alnum:] | letters and digits
[:alpha:] | letters
[:ascii:] | character codes 0 - 127
[:blank:] | space or tab only
[:cntrl:] | control characters
[:digit:] | decimal digits (same as \d)
[:graph:] | printing characters, excluding space
[:lower:] | lower case letters
[:print:] | printing characters, including space
[:punct:] | printing characters, excluding letters and digits
[:space:] | white space (not quite the same as \s, it include VT: chr(11) )
[:upper:] | upper case letters
[:word:] | "word" characters (same as \w)
[:xdigit:] | hexadecimal digits

Related

StringInStr, StringRegExpReplace

Example

;Option 1, using offset
$nOffset = 1
While 1
$array = StringRegExp('<test>a</test> <test>b</test> <test>c</Test>', '<(?i)test>(.*?)</(?i)test>', 1, $nOffset)

If @error = 0 Then
$nOffset = @extended
Else
ExitLoop
EndIf
for $i = 0 to UBound($array) - 1
msgbox(0, "RegExp Test with Option 1 - " & $i, $array[$i])
Next
WEnd

;Option 2, single return, php/preg_match() style
$array = StringRegExp('<test>a</test> <test>b</test> <test>c</Test>', '<(?i)test>(.*?)</(?i)test>', 2)
for $i = 0 to UBound($array) - 1
msgbox(0, "RegExp Test with Option 2 - " & $i, $array[$i])
Next

;Option 3, global return, old AutoIt style
$array = StringRegExp('<test>a</test> <test>b</test> <test>c</Test>', '<(?i)test>(.*?)</(?i)test>', 3)

for $i = 0 to UBound($array) - 1
msgbox(0, "RegExp Test with Option 3 - " & $i, $array[$i])
Next

;Option 4, global return, php/preg_match_all() style
$array = StringRegExp('F1oF2oF3o', '(F.o)*?', 4)

for $i = 0 to UBound($array) - 1

$match = $array[$i]
for $j = 0 to UBound($match) - 1
msgbox(0, "cRegExp Test with Option 4 - " & $i & ',' & $j, $match[$j])
Next
Next


Function StringRegExpReplace

Function Reference

StringRegExpReplace

Replace text in a string based on regular expressions.

StringRegExpReplace ( "test", "pattern", "replace", [ count ] )

Parameters

test | The string to check
pattern | The regular expression to compare. See StringRegExp for pattern definition characters.
replace | The text to replace the regular expression matching text with. To insert matched group text, \0 - \9 (or $0 - $9) can be used as back-references.
count | [optional] The number of times to execute the replacement in the string. The default is 0. Use 0 for global replacement.

Return Value

@Error | Meaning
0 | Executed properly. Check @Extended for the number of replacements performed.
2 | Pattern invalid. @Extended = offset of error in pattern.

Remarks

Related

StringReplace, StringRegExp

Example

MsgBox(0, "Regular Expression Replace Test", StringRegExpReplace("Where have all the flowers gone, long time passing?", "[aeiou]", "@"))


Function StringReplace

Function Reference

StringReplace

Replaces substrings in a string.

StringReplace ( "string", "searchstring" or start, "replacestring" [, count [, casesense]] )

Parameters

string | The string to evaluate.
searchstring | The substring to search for or the character position to start the replacement.
replacestring | The replacement string.
count | [optional] The number of times to replace the searchstring. 0 = all searchstrings will be replaced (default)
casesense | [optional] Flag to indicate if the operations should be case sensitive. 0 = not case sensitive, using the user's locale (default) 1 = case sensitive 2 = not case sensitive, using a basic/faster comparison

Return Value

Returns the new string, the number of replacements performed is stored in @extended.

Remarks

The search/replace is performed left-to-right. Thus, StringReplace("aaa", "aa", "bb") returns "bba"

If the start method is used the count and casesense parameters are ignored. If the replacestring cannot be stored a blank string is returned and @error is set to 1.

Related

String, StringLeft, StringLen, StringLower, StringMid, StringRight, StringTrimLeft, StringTrimRight, StringUpper

Example

$text = StringReplace("this is a line of text", " ", "-")
$numreplacements = @extended
MsgBox(0, "New string is", $text)
MsgBox(0, "The number of replacements done was", $numreplacements)


Function StringRight

Function Reference

StringRight

Returns a number of characters from the right-hand side of a string.

StringRight ( "string", count )

Parameters

string | The string to evaluate.
count | The number of characters to get.

Return Value

Returns a string containing the rightmost count characters of the string.

Remarks

If count exceeds string length, the entire string is returned.
If count is negative, an empty string is returned.

Related

String, StringInStr, StringLeft, StringLen, StringLower, StringMid, StringTrimLeft, StringTrimRight, StringUpper

Example

$var = StringRight("I am a string", 3)
MsgBox(0, "Rightmost 3 characters are:", $var)


Function StringTrimLeft

Function Reference

StringTrimLeft

Trims a number of characters from the left hand side of a string.

StringTrimLeft ( "string", count )

Parameters

string | The string to evaluate.
count | The number of characters to trim.

Return Value

Returns the string trimmed by count characters from the left.

Remarks

If count is out-of-bounds, an empty string is returned.
StringTrimLeft($str, $n) is functionally equivalent to StringRight($str, StringLen($str) - $n)

Related

String, StringInStr, StringLeft, StringLen, StringLower, StringMid, StringRight, StringTrimRight, StringUpper

Example

$result = StringTrimLeft("I am a string", 3)
MsgBox(0, "String without leftmost 3 characters is:", $result)


Function StringTrimRight

Function Reference

StringTrimRight

Trims a number of characters from the right hand side of a string.

StringTrimRight ( "string", count )

Parameters

string | The string to evaluate.
count | The number of characters to trim.

Return Value

Returns the string trimmed by count characters from the right.

Remarks

If count is out-of-bounds, an empty string is returned.
StringTrimRight($str, $n) is functionally equivalent to StringLeft($str, StringLen($str) - $n)

Related

String, StringInStr, StringLeft, StringLen, StringLower, StringMid, StringRight, StringTrimLeft, StringUpper

Example

$result = StringTrimRight("I am a string", 3)
MsgBox(0, "String without rightmost 3 characters is:", $result)


Function StringUpper

Function Reference

StringUpper

Converts a string to uppercase.

StringUpper ( "string" )

Parameters

string The string to convert.

Return Value

Returns the string converted to uppercase.

Remarks

None.

Related

StringIsLower, StringIsUpper, String, StringInStr, StringLeft, StringLen, StringLower, StringMid, StringRight, StringTrimLeft, StringTrimRight

Example

$result = StringUpper("I am 4-word string")
MsgBox(0, "String converted to uppercase is:", $result)


Function WinActivate

Function Reference

WinActivate

Activates (gives focus to) a window.

WinActivate ( "title" [, "text"] )

Parameters

title | The title of the window to activate. See Title special definition.
text | [optional] The text of the window to activate.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if window is not found.

Remarks

You can use the WinActive function to check if WinActivate succeeded. If multiple windows match the criteria, the window that was most recently active is the one activated. WinActivate works on minimized windows. However, a window that is "Always On Top" could still cover up a window you Activated.

Related

WinClose, WinSetState, WinTitleMatchMode (Option)

Example

WinActivate("Untitled - Notepad", "")


Function WinActive

Function Reference

WinActive

Checks to see if a specified window exists and is currently active.

WinActive ( "title" [, "text"] )

Parameters

title | The title of the window to check. See Title special definition.
text | [optional] The text of the window to check.

Return Value

Success: | Returns 1 if window is active.
Failure: | Returns 0 otherwise.

Remarks

None.

Related

WinExists, WinWait, WinWaitActive, WinWaitClose, WinWaitNotActive, WinTitleMatchMode (Option)

Example

If WinActive("Untitled -") Then
MsgBox(0, "", "Window was active")
EndIf


Function WinClose

Function Reference

WinClose

Closes a window.

WinClose ( "title" [, "text"] )

Parameters

title | The title of the window to close. See Title special definition.
text | [optional] The text of the window to close.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if window is not found.

Remarks

This function sends a close message to a window, the result depends on the window (it may ask to save data, etc.). To force a window to close, use the WinKill function. If multiple windows match the criteria, the window that was most recently active is closed.

Related

WinActivate, WinExists, WinKill, WinSetState, WinTitleMatchMode (Option)

Example

WinClose("Untitled - Notepad", "")


Function WinExists

Function Reference

WinExists

Checks to see if a specified window exists.

WinExists ( "title" [, "text"] )

Parameters

title | The title of the window to check. See Title special definition.
text | [optional] The text of the window to check.

Return Value

Success: | Returns 1 if the window exists.
Failure: | Returns 0 otherwise.

Remarks

WinExists will return 1 even if the window is hidden.

Related

WinActive, WinWait, WinWaitActive, WinWaitClose, WinWaitNotActive, WinTitleMatchMode (Option)

Example

If WinExists("Untitled -") Then
MsgBox(0, "", "Window exists")
EndIf


Function WinGetClassList

Function Reference

WinGetClassList

Retrieves the classes from a window.

WinGetClassList ( "title" [, "text"] )

Parameters

title | The title of the window to read. See Title special definition.
text | [optional] The text of the window to read.

Return Value

Success: | Returns a string containing the window classes read.
Failure: | Returns "" and sets @error to 1 if no window matches the criteria.

Remarks

Class names are linefeed (@LF) separated. WinGetClassList works on both minimized and hidden windows. Up to 64KB of text can be retrieved. If multiple windows match the criteria, the classes are read from the most recently active window.

Related

WinGetText, ControlCommand

Example

$text = WinGetClassList("Untitled -", "")
MsgBox(0, "Text read was:", $text)


Function WinGetClientSize

Function Reference

WinGetClientSize

Retrieves the size of a given window's client area.

WinGetClientSize ( "title" [, "text"] )

Parameters

title | The title of the window to read. See Title special definition.
text | [optional] The text of the window to read.

Return Value

Success: | Returns a 2-element array containing the following information:
 | $array[0] = Width of window's client area
 | $array[1] = Height of window's client area
Failure: | Returns 0 and sets @error to 1 if windows is not found.

Remarks

If the window is minimized, the returned width and height values are both zero. However, WinGetClientSize works correctly on (non-minimized) hidden windows. If the window title "Program Manager" is used, the function will return the size of the desktop. WinGetClientSize("") matches the active window. If multiple windows match the criteria, the most recently active window is used.

Related

WinGetPos, WinMove

Example

$size = WinGetClientSize("")
MsgBox(0, "Active window's client size is (width,height):", $size[0] & " " & $size[1])


Function WinGetHandle

Function Reference

WinGetHandle

Retrieves the internal handle of a window.

WinGetHandle ( "title" [, "text"] )

Parameters

title | The title of the window to read. See Title special definition.
text | [optional] The text of the window to read.

Return Value

Success: | Returns handle to the window.
Failure: | Returns "" (blank string) and sets @error to 1 if no window matches the criteria.

Remarks

This function allows you to use handles to specify windows rather than "title" and "text".
Once you have obtained the handle you can access the required window even if its title changes.

Related

WinSetTitle

Example

; Identify the Notepad window that contains the text "this one" and get a handle to it

; Change into the WinTitleMatchMode that supports classnames and handles
AutoItSetOption("WinTitleMatchMode", 4)

; Get the handle of a notepad window that contains "this one"
$handle = WinGetHandle("classname=Notepad", "this one")
If @error Then
MsgBox(4096, "Error", "Could not find the correct window")
Else
; Send some text directly to this window's edit control
ControlSend($handle, "", "Edit1", "AbCdE")
EndIf


Function WinGetPos

Function Reference

WinGetPos

Retrieves the position and size of a given window.

WinGetPos ( "title" [, "text"] )

Parameters

title | The title of the window to read. See Title special definition.
text | [optional] The text of the window to read.

Return Value

Success: | Returns a 4-element array containing the following information:
 | $array[0] = X position
 | $array[1] = Y position
 | $array[2] = Width
 | $array[3] = Height
Failure: | Returns 0 and sets @error to 1 if windows is not found.

Remarks

WinGetPos returns negative numbers such as -32000 for minimized windows, but works fine with (non-minimized) hidden windows.
If the window title "Program Manager" is used, the function will return the size of the desktop. If multiple windows match the criteria, the most recently active window is used.

Related

WinGetClientSize, WinMove

Example

$size = WinGetPos("")
MsgBox(0, "Active window stats (x,y,width,height):", $size[0] & " " & $size[1] & " " & $size[2] & " " & $size[3])


Function WinGetText

Function Reference

WinGetText

Retrieves the text from a window.

WinGetText ( "title" [, "text"] )

Parameters

title | The title of the window to read. See Title special definition.
text | [optional] The text of the window to read.

Return Value

Success: | Returns a string containing the window text read.
Failure: | Returns numeric 0 if no title match.

Remarks

Up to 64KB of window text can be retrieved. WinGetText works on minimized windows, but only works on hidden windows if you've set AutoItSetOption("WinDetectHiddenText", 1)
If multiple windows match the criteria for WinGetText, the information for the most recently active match is returned.
Use WinGetText("") to get the active window's text.

Related

WinGetTitle, ControlGetText

Example

$text = WinGetText("Untitled -", "")
MsgBox(0, "Text read was:", $text)


Function WinGetTitle

Function Reference

WinGetTitle

Retrieves the full title from a window.

WinGetTitle ( "title" [, "text"] )

Parameters

title | The title of the window to read. See Title special definition.
text | [optional] The text of the window to read.

Return Value

Success: | Returns a string containing the complete window title.
Failure: | Returns numeric 0 if no title match.

Remarks

WinGetTitle("") returns the active window's title. WinGetTitle works on both minimized and hidden windows. If multiple windows match the criteria, the most recently active window is used.

Related

AutoItWinGetTitle, WinGetText, WinSetTitle, WinTitleMatchMode (Option)

Example

$title = WinGetTitle("Untitled -", "")
MsgBox(0, "Full title read was:", $title)


Function WinKill

Function Reference

WinKill

Forces a window to close.

WinKill ( "title" [, "text"] )

Parameters

title | The title of the window to close. See Title special definition.
text | [optional] The text of the window to close.

Return Value

None. (Always returns 1 regardless of success.)

Remarks

The difference between this function and WinClose is that WinKill will forcibly terminate the window if it doesn't close quickly enough. Consequently, a user might not have time to respond to dialogs prompting the user to save data. Although WinKill can work on both minimized and hidden windows, some windows (notably explorer windows) can only be terminated using WinClose.

Related

WinActivate, WinClose, WinSetState, ProcessClose

Example

WinKill("Untitled - ", "")


Function WinList

Function Reference

WinList

Retrieves a list of windows.

WinList ( ["title" [, "text"]] )

Parameters

title | [optional] The title of the window to read.
text | [optional] The text of the window to read.

Return Value

Returns an array of matching window titles and handles.

Remarks

If no title and text is given then all top-level windows are returned.

The array returned is two-dimensional and is made up as follows:
$array[0][0] = Number of windows returned
$array[1][0] = 1st window title
$array[1][1] = 1st window handle (HWND)
$array[2][0] = 2nd window title
$array[2][1] = 2nd window handle (HWND)
...
$array[n][0] = nth window title
$array[n][1] = nth window handle (HWND)

Related

WinGetHandle

Example

$var = WinList()

For $i = 1 to $var[0][0]
; Only display visble windows that have a title
If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then
MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1])
EndIf
Next

Func IsVisible($handle)
If BitAnd( WinGetState($handle), 2 ) Then
Return 1
Else
Return 0
EndIf

EndFunc


Function WinMenuSelectItem

Function Reference

WinMenuSelectItem

Invokes a menu item of a window.

WinMenuSelectItem ( "title", "text", "item" [, "item" [, "item" [, "item" [, "item" [, "item" [, "item"]]]]]] )

Parameters

title | The title of the window to read. See Title special definition.
text | The text of the window to read.
item | Text of Menu Item
item | [optional] Text of SubMenu item
item | [optional] Text of SubMenu item
item | [optional] Text of SubMenu item
item | [optional] Text of SubMenu item
item | [optional] Text of SubMenu item
item | [optional] Text of SubMenu item

Return Value

Success: | Returns 1.
Failure: | Returns 0 if the menu could not be found.

Remarks

You should note that underlined menu items actually contain a & character to indicate the underlining. Thus, the menu item File would actually require the text "&File", and Convert would require "Con&vert" You can access menu items up to six levels deep; and the window can be inactive, minimized, and/or even hidden.

WinMenuSelectItem will only work on standard menus. Unfortunately, many menus in use today are actually custom written or toolbars "pretending" to be menus. This is true for most Microsoft applications.

Related

ControlCommand, Send

Example

; This will select File, Page Setup in notepad
WinMenuSelectItem("Untitled - ", "", "&File", "Page Set&up..." )


Function WinMove

Function Reference

WinMove

Moves and/or resizes a window.

WinMove ( "title", "text", x, y [, width [, height[, speed]]] )

Parameters

title | The title of the window to move/resize. See Title special definition.
text | The text of the window to move/resize.
x | X coordinate to move to.
y | Y coordinate to move to.
width | [optional] New width of the window.
height | [optional] New height of the window.
speed | [optional] the speed to move the windows in the range 1 (fastest) to 100 (slowest). If not defined the move is instantaneous.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if window is not found.

Remarks

WinMove has no effect on minimized windows, but WinMove works on hidden windows.
If the width and height are small (or negative), the window will go no smaller than 112 x 27 pixels. If width and height are large, the window will go no larger than approximately [12+@DesktopWidth] x [12+@DesktopHeight] pixels.
Negative values are allowed for the x and y coordinates. In fact, you can move a window off screen; and if the window's program is one that remembers its last window position, the window will appear in the corner (but fully on-screen) the next time you launch the program.
If multiple windows match the criteria, the most recently active window is used.

If x and y equal to the Default keyword no move occurs, just resizing.

When speed is used the move is done with the new size.

Related

WinActivate, WinClose, WinGetClientSize, WinGetPos, WinSetState, Default

Example

WinMove("Untitled -", "", 0, 0, 200, 200)


Function WinSetState

Function Reference

WinSetState

Shows, hides, minimizes, maximizes, or restores a window.

WinSetState ( "title", "text", flag )

Parameters

title | The title of the window to show. See Title special definition.
text | The text of the window to show.
flag | The "show" flag of the executed program: @SW_HIDE = Hide window @SW_SHOW = Shows a previously hidden window @SW_MINIMIZE = Minimize window @SW_MAXIMIZE = Maximize window @SW_RESTORE = Undoes a window minimization or maximization @SW_DISABLE = Disables the window @SW_ENABLE = Enables the window

Return Value

Success: | Returns 1.
Failure: | Returns 0 if window is not found.

Remarks

If multiple windows match the criteria, the most recently active window is used.
@SW_MINIMIZE and @SW_MAXIMIZE even work on modal dialog windows.

Related

WinActivate, WinClose

Example

WinSetState("Untitled -", "", @SW_HIDE)
Sleep(3000)
WinSetState("Untitled -", "", @SW_SHOW)


Function WinSetTitle

Function Reference

WinSetTitle

Changes the title of a window.

WinSetTitle ( "title", "text", "newtitle" )

Parameters

title | The title of the window to change. See Title special definition.
text | The text of the window to change.
newtitle | The new title to give to the window.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if window is not found.

Remarks

If multiple windows match the criteria the title of most recently active window is changed.

Related

AutoItWinSetTitle, WinGetTitle, WinTitleMatchMode (Option)

Example

WinSetTitle("Untitled - ", "", "My New Notepad")


Function WinWait

Function Reference

WinWait

Pauses execution of the script until the requested window exists.

WinWait ( "title" [, "text" [, timeout]] )

Parameters

title | The title of the window to check. See Title special definition.
text | [optional] The text of the window to check.
timeout | [optional] Timeout in seconds

Return Value

Success: | Returns 1.
Failure: | Returns 0 if timeout occurred.

Remarks

None.

Related

WinActive, WinExists, WinWaitActive, WinWaitClose, WinWaitNotActive, WinWaitDelay (Option)

Example

;Wait for the window "Untitled" to exist

Run("notepad")
WinWait("Untitled")

;Wait a maximum of 5 seconds for "Untitled" to exist
WinWait("Untitled", "", 5)


Function WinWaitActive

Function Reference

WinWaitActive

Pauses execution of the script until the requested window is active.

WinWaitActive ( "title" [, "text" [, timeout]] )

Parameters

title | The title of the window to check. See Title special definition.
text | [optional] The text of the window to check.
timeout | [optional] Timeout in seconds

Return Value

Success: | Returns 1.
Failure: | Returns 0 if timeout occurred.

Remarks

None.

Related

WinActive, WinExists, WinWait, WinWaitClose, WinWaitNotActive, WinWaitDelay (Option)

Example

;Wait for the window "Untitled" to exist and be active
WinWaitActive("Untitled")

;Wait a maximum of 5 seconds for "Untitled" to exist and be active
WinWaitActive("Untitled", "", 5)


Function WinWaitClose

Function Reference

WinWaitClose

Pauses execution of the script until the requested window does not exist.

WinWaitClose ( "title" [, "text" [, timeout]] )

Parameters

title | The title of the window to check. See Title special definition.
text | [optional] The text of the window to check.
timeout | [optional] Timeout in seconds

Return Value

Success: | Returns 1.
Failure: | Returns 0 if timeout occurred.

Remarks

If the window already doesn't exist when this function is called it will return 1 immediately. The window is polled every 250 milliseconds or so.

Related

WinActive, WinExists, WinWait, WinWaitActive, WinWaitNotActive, WinWaitDelay (Option)

Example

;Wait for the window "Untitled" to not exist
WinWaitClose("Untitled")

;Wait a maximum of 5 seconds for "Untitled" to not exist
WinWaitClose("Untitled", "", 5)


Function WinWaitNotActive

Function Reference

WinWaitNotActive

Pauses execution of the script until the requested window is not active.

WinWaitNotActive ( "title" [, "text" [, timeout]] )

Parameters

title | The title of the window to check. See Title special definition.
text | [optional] The text of the window to check.
timeout | [optional] Timeout in seconds

Return Value

Success: | Returns 1.
Failure: | Returns 0 if timeout occurred.

Remarks

The script polls for a window match every 250 milliseconds or so.

Related

WinActive, WinExists, WinWait, WinWaitActive, WinWaitClose, WinWaitDelay (Option)

Example

;Wait for the window "Untitled" to not be active
WinWaitNotActive("Untitled")

;Wait a maximum of 5 seconds for "Untitled" to not be active
WinWaitNotActive("Untitled", "", 5)


Functions

GUI Control creation Function Reference

Below is a complete list of the GUI control creation functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
GUICtrlCreateAvi | Creates an AVI video control for the GUI.
GUICtrlCreateButton | Creates a Button control for the GUI.
GUICtrlCreateCheckbox | Creates a Checkbox control for the GUI.
GUICtrlCreateCombo | Creates a ComboBox control for the GUI.
GUICtrlCreateContextMenu | Creates a context menu for a control or entire GUI window.
GUICtrlCreateDate | Creates a date control for the GUI.
GUICtrlCreateDummy | Creates a Dummy control for the GUI.
GUICtrlCreateEdit | Creates an Edit control for the GUI.
GUICtrlCreateGroup | Creates a Group control for the GUI.
GUICtrlCreateIcon | Creates an Icon control for the GUI.
GUICtrlCreateInput | Creates an Input control for the GUI.
GUICtrlCreateLabel | Creates a static Label control for the GUI.
GUICtrlCreateList | Creates a List control for the GUI.
GUICtrlCreateListView | Creates a ListView control for the GUI.
GUICtrlCreateListViewItem | Creates a ListView item.
GUICtrlCreateMenu | Creates a Menu control for the GUI.
GUICtrlCreateMenuItem | Creates a MenuItem control for the GUI.
GUICtrlCreateObj | Creates an ActiveX control in the GUI.
GUICtrlCreatePic | Creates a Picture control for the GUI.
GUICtrlCreateProgress | Creates a Progress control for the GUI.
GUICtrlCreateRadio | Creates a Radio button control for the GUI.
GUICtrlCreateSlider | Creates a Slider control for the GUI.
GUICtrlCreateTab | Creates a Tab control for the GUI.
GUICtrlCreateTabItem | Creates a TabItem control for the GUI.
GUICtrlCreateTreeView | Creates a TreeView control for the GUI.
GUICtrlCreateTreeViewItem | Creates a TreeViewItem control for the GUI.
GUICtrlCreateUpdown | Creates an UpDown control for the GUI.


Functions

GUI Control Management Function Reference

Below is a complete list of the GUI control update functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
GUICtrlSetBkColor | Sets the background color of a control.
GUICtrlSetColor | Sets the text color of a control.
GUICtrlSetData | Modifies the data for a control.
GUICtrlSetCursor | Sets mouse cursor icon for a particular control.
GUICtrlSetFont | Sets the Font parameter for a control.
GUICtrlSetImage | Sets the bitmap or icon image to use for a control.
GUICtrlSetLimit | Limit the number of characters/pixels for a control.
GUICtrlSetOnEvent | Defines a user-defined function to be called when a control is clicked.
GUICtrlSetPos | Changes the position of a control within the GUI window.
GUICtrlSetResizing | Defines the resizing method used by a control.
GUICtrlSetState | Changes the state of a control.
GUICtrlSetStyle | Changes the style of a control.
GUICtrlSetTip | Sets the tip text associated with a control.

Function | Description
GUICtrlRecvMsg | Retrieve information from a control.
GUICtrlSendMsg | Send a message to a control..
GUICtrlSendToDummy | Sends a message to a Dummy control.


Functions

GUI update Function Reference

Below is a complete list of the GUI update functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
GUISetBkColor | Sets the background color of the GUI window.
GUISetCoord | Sets absolute coordinates for the next control.
GUISetCursor | Sets the mouse cursor icon for a GUI window.
GUISetFont | Sets the default font for a GUI window.
GUISetHelp | Sets an executable file that will be run when F1 is pressed.
GUISetIcon | Sets the icon used in a GUI window.
GUISetState | Changes the state of a GUI window.
GUISetStyle | Changes the styles of a GUI window.


AutoIt Window Info Tool

AutoIt Window Information Tool

AutoIt v3 comes with a standalone tool called the AutoIt Window Info Tool (Program Files\AutoIt3\AU3Info.exe). AU3Info allows you to get information from a specified window that can be used to effectively automate it. Information that can be obtained includes:

  • Window titles
  • Text on the window (visible and hidden)
  • Window size and position
  • Contents of the status bar
  • Position of the mouse pointer
  • Colour of the pixels underneath the mouse pointer
  • Details of the Control underneath the mouse pointer

To use AU3Info just run it (from the command line or Start menu). AU3Info will remain the top most window at all times so that you can read it. Once active move to the window you are interested in and activate it - the contents of AU3Info will change to show the information that is available. With the help of AU3Info you should be automating in no time!

When AU3Info is running you may want to copy text directly from it using CTRL-C and then paste it into your script to avoid spelling/case errors. For the tabs that have information in a list view (like the control information shown below) just double-click on an entry to copy it to the clipboard. This can be difficult when you want to capture pixel/mouse information as it keeps changing! To help with this you can "freeze" the output of AU3Info by pressing CTRL-ALT-F. Press the keys again to "unfreeze".

Here is an example of AU3Info in use with the Windows "WordPad" editor:


COM Reference

COM Extensions to AutoIt

A short introduction

What is COM?

COM stands for "Component Object Model". It is the Microsoft way to interconnect software using a common interface. These interfaces are defined in a COM Object.

Before COM, you had to know the exact implementation of a program before you could 'interface' with it. Using COM, you can now "talk" to its defined Object(s). The only things you have to know are the names of the Objects that are used and which 'properties' or 'methods' they have.

What are (Object) properties or methods?

These are the two basic characteristics of an Object. You can see a 'property' as the data storage of an Object. A 'method' can be seen as an internal function call to do something with the data.

Do I need COM in my AutoIt script?

It just depends. AutoIt has a lot of built-in functions and a huge library of UDF's. You can do most of your programming with these. However if you need special 'interfacing' to other applications, using COM might save you some lines of script. Scripters have to be aware that the existence of COM Objects depend HEAVILY on the Operating System AND the installed software. The examples below have all been tested under a 'plain' Windows XP professional version with Microsoft Office 2000.

An example usage of COM in AutoIt

Let's say you want to minimize all open windows. You could do this using regular AutoIt functions like WinList and WinSetState. However, two lines of COM-code can give you the same result:

$oShell = ObjCreate("shell.application")

$oShell.MinimizeAll

Side note: The example is no longer the shortest way to minimize all windows after the introduction of the WinMinimizeAll() function in AutoIt.

On the first line we create a new object called "shell.application". This is an internal Windows object, defined in shell32.dll. The pointer to this new object is assigned to the variable $oShell. $oShell is from now on an Object variable.

On the second line, we use a Method called "MinimizeAll" to the oShell object. This will minimize all windows.

All Windows versions have a huge amount of internal Objects for various purposes. And applications like Excel or Word have also their own set of Objects.

However, it is sometimes difficult to get a list of all existing Objects defined on your system with their corresponding properties and methods. Searching at Microsoft.com or Google.com might give you some clues about the Object 'X' you want to use.

For instance, you can find information about the "shell.application" object at:

http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_programming/objectmap.asp

To get a peek on all objects currently installed on your system, the "OLE/COM Object Viewer" is a very helpful tool. This tool will be explained in a separate section below.

Let's do another example. We would like to get a HTML source code from a certain web page. You could use the internal InetGet() function to save the result to a file and retrieve it back again with FileRead(). But these lines of code do the same:

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("GET","http://www.AutoItScript.com")
$oHTTP.Send()
$HTMLSource = $oHTTP.Responsetext

The (string) variable $HTMLSource now contains the complete HTML code of the AutoItScript.com home page (that is, the top HTML-Frame).

(Information about the "winhttp.winhttprequest" object can be found at:
http://msdn.microsoft.com/library/en-us/winhttp/http/winhttprequest.asp )

Please mind this: The existence of Objects depend on the computer's operating system and installed programs. For example, the winhttp.winhttprequest.5.1 object only exists on computers that have at least Internet Explorer version 5 installed. When you are sharing scripts that use COM objects, be sure the objects exist on all computers.

Object variables behave a bit different than other types of AutoIt variables. An Object is not a real value, but a 'pointer' to something outside the script. So you can't perform arithmetic's, nor equations on Object variables. When you assign an Object variable a different value, the 'pointer' will automatically be released. You can, for instance, force deletion of an Object by assigning it any number or any text value.

$oHTTP = ObjCreate("winhttp.winhttprequest.5.1") ; Object is created
$oHTTP=0 ; Object is deleted

You don't need to delete Objects when you are finished. If a script exits, AutoIt tries to release all active references to Objects that had been created in the script. Same thing happens when you had defined a local Object variable inside a function, and the function ends with a return.

Automation using COM

A very popular application of COM is to 'automate' programs. Instead of using the regular AutoIt functions like Send() or WinActivate(), you can make use of the Objects that are defined inside the program.

Here is an example that 'automates' Microsoft Excel:

$oExcel = ObjCreate("Excel.Application") ; Create an Excel Object
$oExcel.Visible = 1 ; Let Excel show itself
$oExcel.WorkBooks.Add ; Add a new workbook
$oExcel.ActiveWorkBook.ActiveSheet.Cells(1,1).Value="test" ; Fill a cell
sleep(4000) ;See the results for 4 seconds
$oExcel.ActiveWorkBook.Saved = 1 ; Simulate a save of the Workbook
$oExcel.Quit ; Quit Excel

The complexity of controlling other programs depends on that specific program, not on the AutoIt script. If something does not work as expected you might need to consult the applications' documentation and not the AutoIt help.

Special Statements

In AutoIt, two special statements are designed for COM usage:

WITH/ENDWITH and the FOR/IN/NEXT loop.

WITH..ENDWITH

The WITH/ENDWITH statement does not add functionality, but it makes your script easier to read. For instance, the previous example using Excel can also be written as:

$oExcel = ObjCreate("Excel.Application") ; Create an Excel Object

WITH $oExcel
.Visible = 1 ; Let Excel show itself
.WorkBooks.Add ; Add a new workbook
.ActiveWorkBook.ActiveSheet.Cells(1,1).Value="test" ; Fill a cell
sleep(4000) ;See the results for 4 seconds
.ActiveWorkBook.Saved = 1 ; Simulate a save of the Workbook
.Quit ; Quit Excel
ENDWITH

This example does not save you a lot of text, but when your object uses long lines of properties/methods, you can shorten it heavily within a WITH statement.

FOR..IN

The FOR...IN loop is required when using Collections. Collections are a special type of Object, that exist out of multiple sub-Objects. You could see them as Arrays (Actually, the FOR..IN statement also works on Array-type variables).

FOR..IN loop using an Array

Below is an example of an FOR..IN loop. This example uses a normal AutoIt array, so it has nothing to do with COM. It's just to show you the principle:

$String = "" ; A string for displaying purposes

$aArray[0]="a" ; We fill an array
$aArray[1]=0 ; with several
$aArray[2]=1.3434 ; different
$aArray[3]="testestestest" ; example values.

FOR $Element IN $aArray ; Here it starts..
$String = $String & $Element & @CRLF
NEXT

; Now Show the results to the user
Msgbox(0,"For..IN Arraytest","Result: " & @CRLF & $String)

FOR..IN loop using an Object

In most cases you can't use 'normal' Object methods to retrieve the elements of a collection. In 'COM'-terms they say you have to 'enumerate' them. This is where the FOR..IN loop comes in.

The Excel example below loops on cells A1:O16 on the current active sheet. If one of the cells has a value less than 5, the code replaces the value with 0 (zero):

$oExcel = ObjCreate("Excel.Application") ; Create an Excel Object

$oExcel.Visible = 1 ; Let Excel show itself
$oExcel.WorkBooks.Add ; Add a new workbook

dim $arr[16][16] ; These lines
for $i = 0 to 15 ; are just
for $j = 0 to 15 ; an example to
$arr[$i][$j] = $i ; create some
next ; cell contents.
next

$oExcel.activesheet.range("A1:O16").value = $arr ; Fill cells with example numbers

sleep(2000) ; Wait a while before continuing

For $cell in $oExcel.ActiveSheet.Range("A1:O16")
If $cell.Value < 5 Then
$cell.Value = 0
Endif
Next

$oExcel.ActiveWorkBook.Saved = 1 ; Simulate a save of the Workbook
sleep(2000) ; Wait a while before closing
$oExcel.Quit ; Quit Excel

Advanced COM usage

The following features of AutoItCOM requires profound knowledge of COM Events and COM Error handling.

If you are a newbie to COM programming, please read some good COM documentation first.

The bible of COM is the book called "Inside OLE 2" by Kraig Brockschmidt (Microsoft Press).

You can also find some COM resources on the internet (not AutoIt related):

http://msdn.microsoft.com/archive/en-us/dnarolegen/html/msdn_aboutole.asp (introduction)

http://www.garybeene.com/vb/tut-obj.htm (about Objects in Visual Basic)

http://java.sun.com/docs/books/tutorial/java/concepts/ (Using objects in Java)

http://msdn.microsoft.com/archive/en-us/dnarguion/html/drgui082399.asp (Object Events in C++)

http://www.garybeene.com/vb/tut-err.htm (Error handling in Visual Basic)

COM Events

Normal COM Automation mainly uses one-way communication. You 'ask' the Object for any properties or results from a Method. However a COM Object can also 'talk back' to your script when it suits it.

This could be very handy in cases you need to wait for some COM-related action to happen.

Instead of writing a kind of loop, asking the Object if something interesting has happened, you can let the Object itself call a specific UDF in your script. Meanwhile you can do other things in your script (almost) simultaneously.

Not all Object to support events. You have to read the Object documentation carefully whether it supports events or not.

If it does, the second thing to know is the type of Events it supports. AutoItCOM can only receive 'dispatch' type events.

Finally you have to know the names of the Events the Object could generate, including their arguments (if any).

Only when you have all this information, you can start building an AutoIt script using COM Events.

Below is a snippet from a script that demonstrates how to receive Events from the Internet Explorer:

$oIE=ObjCreate("InternetExplorer.Application.1")   ; Create an Internet Explorer Object

$EventObject=ObjEvent($oIE,"IEEvent_","DWebBrowserEvents")  ; Start receiving Events.

$oIE.url= "http://www.autoitscript.com"  ; Load an example web page < BR>
;From now on, the $oIE Object generates events during web page load.
;They are handled in the event functions shown below.

;Here you can let the script wait until the user wants to finish.
...(your code here)...

$EventObject.stop            ; Tell IE we want to stop receiving Events
$EventObject=0               ; Kill the Event Object
$oIE.quit                    ; Quit IE
$oIE=0                       ; Remove IE from memory (not really necessary)
Exit                         ; End of main script

; A few Internet Explorer Event Functions.
;
; For the full list of IE Event Functions, see the MSDN WebBrowser documentation at:
; http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/webbrowser.asp

Func IEEvent_StatusTextChange($Text)
; In the complete script (see link below) we show the contents in a GUI Edit box.
    GUICtrlSetData ( $GUIEdit, "IE Status text changed to: " & $Text & @CRLF, "append" )
EndFunc

Func IEEvent_BeforeNavigate($URL, $Flags, $TargetFrameName, $PostData, $Headers, $Cancel)
; In the complete script (see link below) we show the contents in a GUI Edit box.
; Note: the declaration is different from the one on MSDN.
  GUICtrlSetData ( $GUIEdit, "BeforeNavigate: " & $URL & " Flags: " & $Flags & @CRLF, "append")
EndFunc

Click here to view the complete script.

The main line in this script is: $EventObject=ObjEvent($oIE,"IEEvent_",...).
This function takes the object $oIE and reroutes it's events to AutoIt functions whose names start with MYEvent_. The third parameter is optional. It is used when an Object has multiple Event interfaces and you don't want AutoIt to choose one automatically.

The Object responsible for the continuous rerouting is $EventObject. This variable does not require any further attention, unless you want to stop the events.

To stop rerouting Events, you can not just delete the variable like $EventObject="". The reason is that the 'calling' Object is still holding a reference to this variable, and it won't loose it until the Object itself quits. You could solve this problem by killing the 'calling' Object, but you can also tell the Object that you don't want to receive any events by using: $EventObject.Stop.  Then you can (but not really necessary) kill the Event by assigning it any value, like: $EventObject=""

If you know the names of the Events $oIE fires, you can implement the Events you are interested in by creating AutoIt UDF's with the name IE Event_Eventname(optional arguments). Be sure you use the correct number of arguments and in their correct order as specified for THAT Event function.  Otherwise you might end up with unexpected values.

If you don't know (for some reason) the names of the events, you can add a UDF with only the prefix. In this example: Func IEEvent_($Eventname).
When an event is received and no IEEvent_ Eventname UDF exists, this function will be called instead and the name of the event will be placed in the variable $Eventname.

You don't have to implement ALL event functions. Those not implemented will just be ignored.

More script examples using COM Event functions can be found in the tests directory in the AutoIt 3.1.1.xx beta ZIP distribution file, downloadable from: http://www.autoitscript.com/autoit3/files/beta/autoit/

Limitations on COM Events in AutoIt

Some Objects (like the 'WebBrowser') pass arguments to their Event Functions 'by reference'. This is intended to allow the user change these arguments and passing it back to the Object. However, AutoIt uses it's own variable scheme, which is not compatible to COM variables. This means that all values from Objects need to be converted into AutoIt variables, thus loosing the reference to the original memory space. Maybe in the near future we can solve this limitation for you !

COM Error Handling

Using COM without proper error handling can be very tricky. Especially when you are not familiar with the Objects in your script.

An AutoIt script will immediately stop execution when it detects a COM error. This is the default and also the safest setting. In this case you have to take measures in your script to prevent the error from happening.

Only if there is no way to prevent a COM error, you could install an "Error Handler" in which you take action after the error has happened. It is not a solution to make a buggy script work properly. Neither does it catch non-COM related script errors (e.g. declaration and syntax errors).

Error handling is implemented in the same way as a normal COM Event, using ObjEvent() and a user defined COM Event Function. The only difference is the usage of the fixed string "AutoIt.Error" as the name of the object.

An example:

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Install a custom error handler

; Performing a deliberate failure here (object does not exist)
$oIE = ObjCreate("InternetExplorer.Application")
$oIE.visible = 1
$oIE.bogus
if @error then Msgbox(0,"","the previous line got an error.")

Exit

; This is my custom error handler
Func MyErrFunc()
$HexNumber=hex($oMyError.number,8)
Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _
"Number is: " & $HexNumber & @CRLF & _
"Windescription is: " & $oMyError.windescription )

SetError(1) ; something to check for when this function returns
Endfunc

One thing is special about the Error Event Handler, and that is the Object it returns. This is an AutoIt Error Object that contains some useful properties and methods. It's implementation is partly based on the "Err" Object in VB(script):

Properties of the AutoIt Error Object:

.number | The Windows HRESULT value from a COM call
.windescription | The FormatWinError() text derived from .number
.source | Name of the Object generating the error (contents from ExcepInfo.source)
.description | Source Object's description of the error (contents from ExcepInfo.description)
.helpfile | Source Object's helpfile for the error (contents from ExcepInfo.helpfile)
.helpcontext | Source Object's helpfile context id number (contents from ExcepInfo.helpcontext)
.lastdllerror | The number returned from GetLastError()
.scriptline | The script line on which the error was generated

Methods of the AutoIt Error Object:

.raise | Raises an error event, initiated by the user
.clear | Clears the contents of the Error Object (i.e. numbers to 0, strings to "")

A note for UDF writers

You can only have ONE Error Event Handler active per AutoIt script. If you are writing UDF's containing COM functions, you can check if the user has an Error Handler installed as follows:

$sFuncName = ObjEvent("AutoIt.Error")
if $sFuncName <> "" then Msgbox (0,"Test","User has installed Error Handler function: " & $sFuncName)

If no Error Handler was active, you can temporarily install your own during the UDF call.

However, you can never stop an existing Error Handler without releasing the variable it had been assigned to. If the script author had installed a COM Error Handler, it's his responsibility to use a proper function that will also be able to catch COM errors generated by UDF's.

OLE/COM Object Viewer

The "OLE/COM Object Viewer" is a very handy tool to get a peek on all COM objects currently installed on your system. It is part of the Windows 2000 resource kit and can be downloaded for free from: http://www.microsoft.com/windows2000/techinfo/reskit/tools/existing/oleview-o.asp

The setup of this program is a bit awkward. It will not create any start menu icon for you. Instead, a file called oleview.exe will be installed in the C:\Program Files\Resource Kit directory (default install).

When running oleview.exe, some systems will complain about a missing file called iviewers.dll. This file is required, but strangely enough not included in the latest setup. You can obtain this dll from an older version of oleview.exe at: http://download.microsoft.com/download/2/f/1/2f15a59b-6cd7-467b-8ff2-f162c3932235/ovi386.exe. It will install the files by default to the C:\MSTOOLS\BIN directory. You only need the file iviewer.dll. Copy it to the same directory where oleview.exe resides, then register the dll using the command line: regsvr32 iviewers.dll.

Let's do an example with the Oleviewer. Run it and follow this tree: Object Classes->Grouped by Component Category->Control->Microsoft Web Browser.

In the left column you see all COM Interfaces that have been defined for this object. We talk about those later. Take a closer look at the right column. It contains a lot of information to use this object in an AutoIt script. Most important is the "VersionIndependentProgID". This is the name to be used in an ObjCreate, ObjGet or ObjEvent function. Furthermore it contains the directory and filename that contains the object. This can be an EXE, a DLL or an OCX file. InProcServer32 means that the object runs in the same thread as your script (in-process). When you see LocalServer32, the object runs as a separate process. The object must also contain a type library (the lines following "TypeLib="), otherwise it can't be used in an AutoIt script.

The interfaces in the left column are used for several ways of interacting with the object. Some are used for storage (IStorage, IPersist), others for embedding in a GUI (IOleObject, IOleControl). AutoIt uses the IDispatch interface for automation. This interface 'exposes' all scriptable methods and properties that the object supports. If it does not exist, you can't use the object in an AutoIt script.

Let's take a look at this interface. Right-click on the name IDispatch and choose "View..." from the context menu. Then click the "View TypeInfo..." button. (Note: if this button is grayed out, you did not have registered the iviewers.dll file, or the object does not have a type library)

The "ITypeInfo Viewer" window does only show the information that is provided with the object. If the developer decides not to include a help file, you will only see the names of the method/properties and nothing else. The "Microsoft Web Browser" type library is however quite extensive. Just click an item in the left column, and a description will be shown at the right. Sometimes you have to browse through "Inherited Interfaces" to retrieve more methods for the object.

The syntax of the described methods/properties are in C/C++ style. A property described as "HRESULT Resizable([in] VARIANT_BOOL pbOffline)", has to be rewritten in AutoIt like: $Resizable=$Object.Resizable ($Object holds the object created with ObjCreate or ObjGet).

COMmonly mixed up terms

These terms are commonly mixed up with COM, but have a different meaning:

OOP = Object Oriented Programming. A programming technique in which software components are put together from reusable building blocks known as Objects.

DDE = Dynamic Data Exchange.

You can say this is the predecessor of COM. It used IPC to transfer information and commands between different applications.

OLE =Object Linking and Embedding

In his first version, OLE was an extended version of DDE to 'embed' data from one program into another. The current generation of OLE is built on top of COM and is part of ActiveX.

Automation = This is a way of manipulating another application's objects. It is used in OLE, ActiveX and COM.

ActiveX = The next generation OLE with Automation, at first mainly developed to interface between applications over a network (especially web browsers). ActiveX is built on top of COM.

DCOM=Distributed COM. A slight modification to COM, making it able to communicate between different physical computers.

.NET (dot Net)= This is not really a piece of software, but an 'idea' from Microsoft to interconnect just about "everything" through (their) software. "dot Net" is used mainly for Web-based services.

COMmunist = This is not a supporter of COM, but someone who believes in communism (a theory that the common people should own all the property).


Controls

One of the best new features with AutoIt v3 is the ability to work directly with certain types of Window Controls. Almost everything you see on a window is a control of some kind: buttons, listboxes, edit fields, static text are all controls. In fact Notepad is just one big "Edit" control! Because AutoIt works directly with a control they provide a more reliable way to automate than just sending keystrokes.

Note: AutoIt only works with standard Microsoft controls - some applications write their own custom controls which may look like a standard MS control but may resist automation. Experiment!

Using the AutoIt Window Info Tool you can move your mouse around the window you are interested in and you will be given information of the control that is currently under your mouse.

A special description can be used as the controlID parameter used in most of the Control...() functions . This description can be used to identify a control by the following properties:

  • ID - The internal control ID. The Control ID is the internal numeric identifier that windows gives to each control. It is generally the best method of identifying controls. In addition to the AutoIt Window Info Tool, other applications such as screenreaders for the blind and Microsoft tools/APIs may allow you to get this Control ID
  • TEXT - The text on a control, for example "&Next" on a button
  • CLASS - The internal control classname such as "Edit" or "Button"
  • INSTANCE - The 1-based instance when all given properties match
  • CLASSNN - The ClassnameNN value as used in previous versions of AutoIt, such as "Edit1"

One or more properties are used in the controlID parameter of a control command in the format:

[PROPERTY1:Value1; PROPERTY2:Value2]

Note: If this special format is not used then the parameter is taken to be a control ID (if numeric) or the ClassnameNN/text of the control (if a string). Although the special format is more longwinded than these methods it is much less ambiguous.

e.g. Send text to the 1st Edit control in the Notepad window

ControlSend("Untitled - Notepad", "", "[CLASS:Edit; INSTANCE:1]", "This is some text")

or

ControlSend("Untitled - Notepad", "", "[CLASSNN:Edit1]", "This is some text")

or

ControlSend("Untitled - Notepad", "", "Edit1", "This is some text")

e.g. Click on control ID 254 in "My Window"

ControlClick("My Window", "", "[ID:254]")

or

ControlClick("My Window", "", 254)

e.g. Click the 2nd instance of a "Button" control containing the text "Finish"

ControlClick("My Window", "", "[CLASS:Button; TEXT:Finish; INSTANCE:2]")

Control Handle (HWND)

Using the ControlGetHandle function you can determine the Handle or HWND of a control. A handle is the unique identifier that Windows gives controls. The handle changes each time the control is created. This method of accessing controls is generally only designed for users who are familar with working with handles.

Look under the contents for Function Reference \ Window Management \ Controls for a list of the functions that work with controls.


TESTTest-IE6.au3

 ; Example script, showing the usage of COM Event functions.
; Requires at least AutoIt beta version 3.1.1.104 !
;
; See also: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/internetexplorer.asp

; We use a very simple GUI to show the results of our Events.
#include "GUIConstants.au3"
$GUIMain=GUICreate ( "Event Test", 600,500 )
$GUIEdit=GUICtrlCreateEdit ( "Test Log:" & @CRLF, 10, 20, 580, 400)
$GUIProg=GUICtrlCreateProgress ( 10, 5, 580, 10)
$GUIExit=GUICtrlCreateButton ( " Close ", 250, 450, 80, 30)
GUISetState () ;Show GUI

; We prepare the Internet Explorer as our test subject
$oIE=ObjCreate("InternetExplorer.Application.1")
With $oIE
.Visible=1
.Top = (@DesktopHeight-400)/2
.Height=400 ; Make it a bit smaller than our GUI.
.Width=600
.Silent=1 ; Don't show IE's dialog boxes
$IEWnd=HWnd(.hWnd) ; Remember the Window, in case user decides to close it
EndWith

; We choose for a specific Internet Explorer interface 'DWebBrowserEvents' because the IE is subject
; to modifications by e.g. Visual Studio and Adobe Acrobat Reader. If you have IE-plugins installed,
; AutoIt might not be able to find the correct interface automatically.
$EventObject=ObjEvent($oIE,"IEEvent_","DWebBrowserEvents")
if @error then
Msgbox(0,"AutoIt COM Test", _
"ObjEvent: Can't use event interface 'DWebBrowserEvents'. Error code: " & hex(@error,8))
exit
endif

; Now starting to load an example Web page.
$URL = "http://www.AutoItScript.com/"
$oIE.Navigate( $URL )
sleep(1000) ; Give it some time to load the web page

GUISwitch ( $GUIMain ) ; Switch back to our GUI in case IE stealed the focus

; Waiting for user to close the GUI.
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE or $msg = $GUIExit Then ExitLoop
Wend

$EventObject.Stop ; Tell IE we don't want to receive events.
$EventObject=0 ; Kill the Event Object
If WinExists($IEWnd) then $oIE.Quit ; Close IE Window
$oIE=0 ; Remove IE from memory (not really necessary).

GUIDelete () ; Remove GUI

exit ; End of our Demo.

; A few Internet Explorer Event Functions
; See also: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/webbrowser.asp

Func IEEvent_BeforeNavigate($URL, $Flags, $TargetFrameName, $PostData, $Headers, $Cancel)
; Note: the declaration is different from the one on MSDN.
GUICtrlSetData ( $GUIEdit, "BeforeNavigate: " & $URL & " Flags: " & $Flags & " tgframe: " & $TargetFrameName & " Postdat: " & $PostData & " Hdrs: " & $Headers & " canc: " & $Cancel & @CRLF , "append" )
EndFunc

Func IEEvent_ProgressChange($Progress,$ProgressMax)
If $ProgressMax > 0 Then
GUICtrlSetData($GUIProg, ($Progress * 100) / $ProgressMax )
EndIf
EndFunc

Func IEEvent_StatusTextChange($Text)
GUICtrlSetData ( $GUIEdit, "IE Status text changed to: " & $Text & @CRLF , "append" )
EndFunc

Func IEEvent_PropertyChange( $szProperty)
GUICtrlSetData ( $GUIEdit, "IE Changed the value of the property: " & $szProperty & @CRLF , "append" )
EndFunc

Func IEEvent_DownloadComplete()
GUICtrlSetData ( $GUIEdit, "IE has finished a navigation operation" & @CRLF , "append" )
EndFunc

Func IEEvent_NavigateComplete($URL)
; Note: the declaration is different from the one on MSDN.
GUICtrlSetData ( $GUIEdit, "IE has finished loading URL: " & $URL & @CRLF , "append" )
EndFunc

Func IEEvent_($EventName)
; This is an optional event function to catch non-defined events.
; The parameter contains the name of the event being called.
GUICtrlSetData ( $GUIEdit, "Uncatched event: " & $EventName & @CRLF , "append" )
EndFunc


Window Titles and Text (Advanced)

AutoIt operates in one of three "Window matching" modes. The modes are set with the AutoItSetOption function using the WinTitleMatchMode option.

Mode 1 (default)

Matches partial titles from the start.

In this mode the a window titled Untitled - Notepad would be matched by "Untitled - Notepad", "Untitled", "Un", etc.

e.g.

WinWait("Untitled")

Mode 2

Matches any substring in the title.

In this mode a window titled Untitled - Notepad would be matched by "Untitled - Notepad", "Untitled", "Notepad", "pad", etc.

e.g.

WinWait("Notepad")

Mode 3

Exact title match.

In this mode a window titled Untitled - Notepad would only be matched by "Untitled - Notepad"

Mode 4

Advanced mode.

See Advanced Window Descriptions.

Mode -1 to -4

Force lower case match according to other type of match.

Advanced Window Descriptions

A special description can be used as the window title parameter. This description can be used to identify a window by the following properties:

  • TITLE - Window title
  • CLASS - The internal window classname
  • REGEXPTITLE - Window title using a regular expression (if the regular expression is wrong @error will be set to 2)
  • LAST - Last window used in a previous AutoIt command
  • ACTIVE - Currently active window
  • INSTANCE - The 1-based instance when all given properties match

One or more properties are used in the title parameter of a window command in the format:

[PROPERTY1:Value1; PROPERTY2:Value2]

e.g. Wait a window of classname "Notepad"

WinWaitActive("[CLASS:Notepad]", "")

e.g. Close the currently active window

WinClose("[ACTIVE]", "")

e.g. Wait for the 2nd instance of a window with title "My Window" and classname "My Class"

WinWaitActive("[TITLE:My Window; CLASS:My Class; INSTANCE:2]", "")

Window Handles / HWNDs

The variant datatype in AutoIt natively supports window handles (HWNDs). A window handle is a special value that windows assigns to a window each time it is created. When you have a handle you may use it in place of the title parameter in any of the function calls that use the title/text convention. The advantage of using window handles is that if you have multiple copies of an application open - which have the same title/text - you can uniquely identify them when using handles. When you use a window handle for the title parameter then the text parameter is completely ignored.

Various functions such as WinGetHandle, WinList and GUICreate return these handles. It is important to note that a window handle is not classed as a number or string - it is its own special type.

Note: Window handles will work no matter what WinTitleMatchMode is currently in use.

Example

$handle = WinGetHandle("Untitled - Notepad", "")
WinClose($handle)


Window Titles and Text (Basic)

When automating, most windows can be uniquely identified by their title or a combination of their title & text. And by using AutoIt Window Info Tool (or even by sight) this information is easy to obtain. The titles of most windows are fairly obvious, for example Untitled - Notepad is the title of the notepad.exe editor and in many cases this is enough to automate.

Note: If a blank string "" is given for both title and text then the currently Active window will be used (this is not true in some of the more advanced WinTitleMatchModes)!

Window titles and text are case sensitive. You must match the case and punctuation exactly. To avoid problems select the title/text in the Window Info Tool and use ctrl-c to copy it and then paste it directly into your script.
You can force match in lower case using advanced modes.

Most of AutoIt's window functions have space for a title and text entry, here is the WinWaitActive function. This function pauses execution of the script until the specified window appears and is active.

WinWaitActive ( "title", ["text"], [timeout] )

title is the only required parameter for this function, both the text and timeout are optional. In some functions the text parameter is not optional, if you do not wish to specify any text then just use "" (a blank string). A blank string, or nothing at all, in the text tells AutoIt that any text is valid.

To use the above function with any notepad window both these methods will work:

WinWaitActive("Untitled - Notepad")

and

WinWaitActive("Untitled - Notepad", "")

If the same notepad window had "This is a line of text" typed into the window, the Window Info Tool would show:

Note that the Window Info Tool has seen the title and text of the notepad window. Whatever the Window Info Tool can see is what AutoIt can see. Now we have enough information to identify this exact window even if there are lots of other notepad windows open. In this case we use:

WinWaitActive("Untitled - Notepad", "This is some text!")

Window Text

The window text consists of all the text that AutoIt can "see". This will usually be things like the contents of edit controls (as above with "This is a line of text") but will also include other text like:

  • Button text like &Yes, &No, &Next (the & indicates an underlined letter)
  • Dialog text like "Are you sure you wish to continue?"
  • Control text
  • Misc text - sometimes you don't know what it is :)

The important thing is that you can use the text along with the title to uniquely identify a window to work with.

When you specify the text parameter in a window function it is treated as a substring. So for the example above if you used the text "is some " you would get a match.

What has been described is the default mode that AutoIt operates in, there are a number of more advanced modes to use when things are not as simple as this.


Keyword Default

Keyword Reference

Default

Keyword value use in function call.

$var = Default

Parameters

None.

Remarks

This keyword should not be used in computation expression. AutoIt will not detect such situation because it's too much performance penalty.

When used as a parameter passing the behavior is specify in the corresponding AutoIt doc function.
For UDF it is the scripter responsabitly to check is the parameter has been set to Default keyword and to do the behavior he wants.
The passed parameter will be set to Default keyword not to and optional parameter value if defined.

Related

IsKeyWord

Example

WinMove("","",default, default, 200,300) ; just resize the active window (no move)

MyFunc2(Default,Default)

Func MyFunc2($Param1 = Default, $Param2 = 'Two', $Param3 = Default)
If $Param1 = Default Then $Param1 = 'One'
If $Param3 = Default Then $Param3 = 'Three'

MsgBox(0, 'Params', '1 = ' & $Param1 & @LF & _
'2 = ' & $Param2 & @LF & _
'3 = ' & $Param3)
EndFunc


Function _CompareVersion

Function Reference

_CompareVersion

Compares two file versions for equality.

#include <Misc.au3>
_CompareVersion ($sVersion1, $sVersion2)

Parameters

$sVersion1 | The first version
$sVersion2 | The second version

Return Value

On Flag = 1 otherwise the script is exited
Success: | Returns 0 - Both versions equal
 | 1 - Version 1 greater
 | -1 - Version 2 greater
 | @extended can be set as follows: 0 - Numeric comparison; 1 - String comparison
Failure: | @error will be set in the event of a catasrophic error.

Remarks

This will try to use a numerical comparison but fall back on a lexicographical comparison.
See @extended for details about which type was performed.

Related

None.

Example

#include <Misc.au3>

$version1="3.2.3.7"
$version2="3.2.3.10"
If _CompareVersion($version1, $version2) < 0 Then
Msgbox(0,"version1 < version2", $version1 & " " & $version2)
EndIf